Пример #1
0
 /**
  * process command line arguments and execute the specified routine
  * @param array $args command line argument
  * @return mixed result of the executed routine
  */
 public static function main($pArgs = array())
 {
     if (!\is_array($pArgs)) {
         throw new ECommandLineInterface("invalid argruments");
     }
     if (count($pArgs) < 2) {
         print "Usage: savant [PACKAGE] [CONTROLLER]-[ACTION] [ARGUMENTS] \nTry savant --help for more information\n";
     } else {
         $parsedArgs = self::parseArgs($pArgs);
         if (isset($parsedArgs->options) == '--help') {
             print self::getHelp();
             return true;
         }
         $res = AGenericCallInterface::call($parsedArgs->class, $parsedArgs->method, $parsedArgs->args);
         print_r($res);
         return true;
     }
 }
Пример #2
0
 /**
  * call application controller
  * @param MVC\IModel $pModel
  * @return mixed
  */
 public function _callController($pController = null)
 {
     $this->controller = $this->name . '\\Controller\\' . $pController;
     $file = $this->CONTROLLER_DIR . \DIRECTORY_SEPARATOR . $pController . '.php';
     if (\file_exists($file)) {
         require_once $file;
         if (!\method_exists($this->controller, $this->action)) {
             throw new EApplication("could not call action %s of %s", $this->controller, $this->action);
         }
     } else {
         return false;
     }
     $res = AGenericCallInterface::call($this->controller, $this->action);
     return $res;
 }
Пример #3
0
 /**
  * invoke generic call interface to handle call
  * @param string $pClass
  * @param string $pMethod
  * @param array $pArgs
  * @return mixed
  */
 public function call($pClass, $pMethod = 'main', $pArgs = array())
 {
     return AGenericCallInterface::call($pClass, $pMethod, $pArgs);
 }
Пример #4
0
 /**
  * invoke classmethod and return the result
  * @param string $pClass
  * @param string $pMethod
  * @return <type> mixed
  */
 public static function invoke($pClass, $pMethod = '__construct', $pArgs = array())
 {
     if (!\class_exists($pClass)) {
         throw new EBootstrap("class %s dont exists", $pClass);
     }
     if (!\method_exists($pClass, $pMethod)) {
         throw new EBootstrap("method %s of class %s dont exists", $pMethod, $pClass);
     }
     if ($pMethod == '__construct') {
         $res = AGenericCallInterface::call($pClass, $pMethod, $pArgs);
         AOP\AFramework::weave($res, new AOP\JoinPoints\CConstructor($pClass));
     } else {
         AOP\AFramework::weave(null, new AOP\JoinPoints\CMethodCall($pClass, $pMethod, $pArgs));
         $res = AGenericCallInterface::call($pClass, $pMethod, $pArgs);
     }
     return $res;
 }