/** * get model of application * @param string $pModel * @param string $pQuery * @return mixed */ public function _getModel($pModel, $pAction = 'index') { $this->model = $modelName = $this->name . '\\Models\\' . $pModel; $this->action = $pAction; $file = $this->MODELS_DIR . \DIRECTORY_SEPARATOR . $pModel . '.php'; if (!\file_exists($file)) { throw new EApplication("could not find file %s of model %s", $file, $pModel); } include_once $file; AOP\AFramework::weave(null, new AOP\JoinPoints\CClassLoader($this->model, null, $file)); $model = new $modelName(new Storage\CDatabase($modelName::DEFAULT_DB)); if (!$model instanceof Webservice\IRestful && !\method_exists($model, $pAction)) { throw new EApplication("could not call action %s of %s", $pAction, $this->model); } return $model; }
/** * 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; }