コード例 #1
0
ファイル: Module.php プロジェクト: samsonphp/view
 /**
  * Module preparation stage.
  * This function called after module instance creation but before
  * initialization stage.
  *
  * @param array $params Preparation stage parameters
  *
  * @return bool|void Preparation stage result
  */
 public function prepare(array $params = array())
 {
     $this->generator->scan(__SAMSON_CWD__ . '/src');
     //$this->generator->scan(__SAMSON_CWD__.'/app');
     $signature = $this->generator->hash();
     if ($this->cache_refresh($signature)) {
         $this->generator->generate($this->cache_path, array($this, 'viewHandler'));
         // Store cache file
         file_put_contents($signature, '');
     }
     // Add system static variable to all classes
     require_once 'View.php';
     View::$system =& $this->system;
     // Continue parent logic
     return parent::prepare($params);
 }
コード例 #2
0
 public function testHash()
 {
     $generator = new Generator(new \samsonphp\generator\Generator(), '\\test\\view\\');
     $generator->scan(__DIR__);
     $this->assertTrue(strlen($generator->hash()) > 0);
 }