Exemple #1
0
 /**
  * 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);
 }
 public function testHash()
 {
     $generator = new Generator(new \samsonphp\generator\Generator(), '\\test\\view\\');
     $generator->scan(__DIR__);
     $this->assertTrue(strlen($generator->hash()) > 0);
 }