loadController() public static method

Looks for and loads required class via require_once
public static loadController ( $class_name ) : boolean
$class_name
return boolean
コード例 #1
0
ファイル: TaskRunner.php プロジェクト: MUlt1mate/cron-manager
 /**
  * Parses given command, creates new class object and calls its method via call_user_func_array
  * @param string $command
  * @return mixed
  */
 public static function parseAndRunCommand($command)
 {
     try {
         list($class, $method, $args) = TaskManager::parseCommand($command);
         if (!class_exists($class)) {
             TaskLoader::loadController($class);
         }
         $obj = new $class();
         if (!method_exists($obj, $method)) {
             throw new TaskManagerException('method ' . $method . ' not found in class ' . $class);
         }
         return call_user_func_array(array($obj, $method), $args);
     } catch (\Exception $e) {
         echo 'Caught an exception: ' . get_class($e) . ': ' . PHP_EOL . $e->getMessage() . PHP_EOL;
         return false;
     }
 }
コード例 #2
0
 public function testLoadControllerExceptions()
 {
     $this->setExpectedException('mult1mate\\crontab\\TaskManagerException');
     TaskLoader::setClassFolder(__DIR__);
     TaskLoader::loadController('MockClass');
 }