예제 #1
0
파일: Example.php 프로젝트: arroyo/erdiko
 /**
  * Before action hook
  * Anything here gets called immediately BEFORE the Action method runs.
  * Typically used for theming, ACL and other controller wide set up code
  */
 public function _before()
 {
     /** 
      * Important notes about theming:
      * Changing your default site wide theme should be done in the default/application.json file
      *
      * If you want to switch themes in your controller uncomment out this line.
      * $this->setThemeName('my_theme_name');
      * 
      * You can also switch themes on a per action basis.  
      * This would be done by putting this code at the top of your action method
      * $this->setTheme('my_theme_name');
      */
     // $this->setThemeName('my_theme_name');
     // Run the parent beore filter to prep the theme
     parent::_before();
 }
예제 #2
0
 function testGetLayout()
 {
     //First test: Setting a theme object
     $controllerObj = new \erdiko\core\Controller();
     $theme = new erdiko\core\Theme('bootstrap', null, 'default');
     $controllerObj->getResponse()->setTheme($theme);
     $return = $controllerObj->getLayout('1column', null);
     //Get content through file_get_contents function
     $themeFolder = $controllerObj->getResponse()->getTheme()->getThemeFolder();
     $fileName = $themeFolder . '/templates/layouts/1column.php';
     $content = file_get_contents($fileName);
     //Search for the keyword which is right before php tag
     $pos = strrpos($content, 'role="main">');
     $content = substr($content, 0, $pos);
     //Check if two content are matched
     $find = strrpos($return, $content);
     $this->assertGreaterThanOrEqual(0, $find);
     unset($controllerObj);
     //Second test: Setting the theme name
     $controllerObj = new \erdiko\core\Controller();
     $controllerObj->getResponse()->setThemeName('bootstrap');
     $return = $controllerObj->getLayout('1column', null);
     //Validate content
     $find = strrpos($return, $content);
     $this->assertGreaterThanOrEqual(0, $find);
     unset($controllerObj);
 }