Example #1
0
 private function moduleContent($moduleName)
 {
     if ($this->isAdminContext()) {
         return null;
     }
     /**
      * in the admin context (means env options are empty) we do not have to render the module!
      */
     if (empty($moduleName) || count($this->getEnvOptions()) === 0) {
         return null;
     }
     $ctrl = $this->getCfgValue('moduleController');
     $action = $this->getCfgValue('moduleAction');
     $actionArgs = json_decode($this->getCfgValue('moduleActionArgs'), true);
     // get module
     $module = Yii::$app->getModule($moduleName);
     $module->setContext('cms');
     $module->setContextOptions($this->getEnvOptions());
     // start module reflection
     $reflection = new \luya\module\Reflection($module);
     $reflection->setModuleSuffix($this->getEnvOption('restString'));
     if ($ctrl && $action) {
         $reflection->setInitRun($ctrl, $action, $actionArgs);
     }
     $response = $reflection->responseContent();
     return $response;
 }
Example #2
0
 /**
  * @todo: see if $pathAfterRoute could be available in the urlRules, otherwise display default
  * (non-PHPdoc)
  *
  * @see cmsadmin\base.NavItemType::getContent()
  */
 public function getContent()
 {
     $module = $this->getModule();
     $reflection = new \luya\module\Reflection($module);
     $reflection->setModuleSuffix($this->getOption('restString'));
     $response = $reflection->responseContent();
     return $response;
 }
Example #3
0
 public function testModuleObject()
 {
     $ref = new \luya\module\Reflection(Yii::$app->getModule('moduletest'));
     $ref->setInitRun('unit-test-2', 'index', ['x' => 'y']);
     $content = $ref->responseContent();
     $this->assertEquals(5, count($content));
     $this->assertEquals("unit-test-2", $content['id']);
     $this->assertEquals("moduletest", $content['module']);
     $this->assertNotEquals("@app/views/moduletest/unit-test", $content['viewPath']);
     $this->assertEquals("@app/views/moduletest/", $content['moduleLayoutViewPath']);
 }