mirror of https://github.com/hauke68/Magallanes
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
<?php |
|
/* |
|
* This file is part of the Magallanes package. |
|
* |
|
* (c) Andrés Montañez <andres@andresmontanez.com> |
|
* |
|
* For the full copyright and license information, please view the LICENSE |
|
* file that was distributed with this source code. |
|
*/ |
|
|
|
namespace Mage; |
|
|
|
/** |
|
* Magallanes custom Autoload for BuiltIn and Userspace Commands and Tasks. |
|
* |
|
* @author Andrés Montañez <andres@andresmontanez.com> |
|
*/ |
|
class Autoload |
|
{ |
|
/** |
|
* Autoload a Class by it's Class Name |
|
* @param string $className |
|
*/ |
|
public static function autoload($className) |
|
{ |
|
$isVendor = explode('\\', $className); |
|
$isVendor = $isVendor[0] == 'Mage' ? false : true; |
|
|
|
$baseDir = dirname(dirname(__FILE__)); |
|
$classFile = $baseDir . '/' . ($isVendor ? 'vendor/' : '') . str_replace(array('_', '\\'), '/', $className . '.php'); |
|
require_once $classFile; |
|
} |
|
|
|
/** |
|
* Checks if a Class can be loaded. |
|
* @param string $className |
|
* @return boolean |
|
*/ |
|
public static function isLoadable($className) |
|
{ |
|
$baseDir = dirname(dirname(__FILE__)); |
|
$classFile = $baseDir . '/' . str_replace(array('_', '\\'), '/', $className . '.php'); |
|
return (file_exists($classFile) && is_readable($classFile)); |
|
} |
|
|
|
/** |
|
* Loads a User's Tasks |
|
* @param string $taskName |
|
*/ |
|
public static function loadUserTask($taskName) |
|
{ |
|
$classFile = '.mage/tasks/' . ucfirst($taskName) . '.php'; |
|
require_once $classFile; |
|
} |
|
|
|
} |