コード例 #1
0
	public function __call($name, $args) {
    if (is_callable($this->$name)) {
      array_unshift($args, $this);
      return call_user_func_array($this->$name, $args);
    }else{
      rifException::callableException(array(
        'code'=>10,
        'message' => "Undefined method " . $name
      ));
    }
  }
コード例 #2
0
ファイル: rifShell.php プロジェクト: elribonazo/riframework
 public function execute($argv)
 {
     if (php_sapi_name() == 'cli') {
         $shellCommand = $argv[1];
         $reflectionShell = new ReflectionClass($shellCommand);
         $shellAnotations = rifAnotations::getAnnotations($reflectionShell->getDocComment());
         $shell = new $shellCommand();
         $shell->lng = $this->lng;
         unset($argv[0]);
         unset($argv[1]);
         $argv = array_values($argv);
         if (is_array($shellAnotations) && count($shellAnotations)) {
             if (!is_array($shellAnotations['param'])) {
                 $shellParam = explode(" ", $shellAnotations["param"]);
                 if (isset($argv[$shellParam[0]])) {
                     $shell->{$shellParam}[1] = $argv[$shellParam[0]];
                 }
             } else {
                 foreach ($shellAnotations['param'] as $shellParam) {
                     $shellParam = explode(" ", $shellParam);
                     if (isset($argv[$shellParam[0]])) {
                         $shell->{$shellParam}[1] = $argv[$shellParam[0]];
                     }
                 }
             }
         }
         $rifModel = "rifModel";
         if (isset($shell->models) && is_array($shell->models)) {
             foreach ($shell->models as $model) {
                 $shell->{$model} = new $rifModel($this->rifCore->core['config'], new $model());
             }
         }
         if (isset($shell->components) && is_array($shell->components)) {
             foreach ($shell->components as $component) {
                 $shell->{$component} = new $component();
             }
         }
         $shell->run($this->rifCore);
     } else {
         rifException::callableException(array('message' => $this->lng->__("Incorrect command execution")));
     }
 }