private function moduleContent($moduleName) { if ($this->isAdminContext() || empty($moduleName) || count($this->getEnvOptions()) === 0 || !Yii::$app->hasModule($moduleName)) { return; } $ctrl = $this->getCfgValue('moduleController'); $action = $this->getCfgValue('moduleAction', 'index'); $actionArgs = Json::decode($this->getCfgValue('moduleActionArgs', '{}')); // get module $module = Yii::$app->getModule($moduleName); $module->context = 'cms'; // start module reflection $reflection = Yii::createObject(['class' => ModuleReflection::className(), 'module' => $module]); $reflection->suffix = $this->getEnvOption('restString'); // if a controller has been defined we inject a custom starting route for the // module reflection object. if (!empty($ctrl)) { $reflection->defaultRoute($ctrl, $action, $actionArgs); } $response = $reflection->run(); if ($response instanceof Response) { return Yii::$app->end(0, $response); } return $response; }
/** * @todo: see if $pathAfterRoute could be available in the urlRules, otherwise display default * (non-PHPdoc) * * @see luya\cms\base\NavItemType::getContent() */ public function getContent() { if ($this->_content == null) { $module = $this->getModule(); $reflection = Yii::createObject(['class' => ModuleReflection::className(), 'module' => $module]); $reflection->suffix = $this->getOption('restString'); $this->_content = $reflection->run(); $this->controller = $reflection->controller; Yii::$app->menu->setCurrentUrlRule($reflection->getUrlRule()); } return $this->_content; }
public static function reflectionObject(\luya\base\Module $moduleObject) { return Yii::createObject(['class' => ModuleReflection::className(), 'module' => $moduleObject]); }