Beispiel #1
0
 /** Module preparation stage handler */
 public function prepare(array $params = [])
 {
     // Subscribe for CSS handling
     Event::subscribe(Router::E_RESOURCE_COMPILE, [$this, 'compile']);
     Event::subscribe(Compressor::E_RESOURCE_COMPRESS, [$this, 'deCompile']);
     return parent::prepare($params);
 }
Beispiel #2
0
 /** SamsonFramework load preparation stage handler */
 public function prepare(array $params = [])
 {
     $moduleCachePath = array_key_exists('cachePath', $params) ? $params['cachePath'] : $this->cache_path;
     $this->dependencyCache = $moduleCachePath . self::DEPENDENCY_CACHE;
     // Load file manager
     $this->fileManager = array_key_exists('fileManager', $params) ? $params['fileManager'] : new LocalFileManager();
     // Read previous cache file
     if ($this->fileManager->exists($this->dependencyCache)) {
         $this->dependencies = unserialize($this->fileManager->read($this->dependencyCache));
     }
     $this->less = new \lessc();
     Event::subscribe(Router::E_RESOURCE_COMPILE, [$this, 'compiler']);
     Event::subscribe(Router::E_FINISHED, [$this, 'cacheDependencies']);
     return parent::prepare();
 }
Beispiel #3
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);
 }
Beispiel #4
0
 /**
  * Module preparation stage.
  *
  * @return bool Preparation stage result
  */
 public function prepare()
 {
     Event::subscribe(Router::EVENT_CREATED, array($this, 'renderer'));
     return parent::prepare();
 }