Esempio n. 1
0
 /**
  *
  */
 public function flush()
 {
     $this->_header();
     $success = false;
     $config = Libraries::get('app');
     $dir = TwigAdapter::cachePath();
     $trash = $config['resources'] . self::PATH_TO_REMOVE;
     $this->out('Starting cache flush.');
     if (!is_dir($dir)) {
         return $this->error('Cache folder not found... exiting.');
     }
     $this->out('Cache folder found : ' . $dir);
     if (is_dir($trash)) {
         $this->out('Old trash folder found (previous command failure possible), deleting it...');
         $this->_rrmdir($trash);
     }
     $this->out('Moving cache folder to temporary location...');
     rename($dir, $trash);
     $this->out('Deleting temporary cache location...');
     $success = $this->_rrmdir($trash);
     if (!$success) {
         return $this->error('Error while deleting Twig template cache.');
     }
     return $this->out('Success!');
 }
Esempio n. 2
0
 /**
  * Constructor for this adapter - sets relevant default configurations for Twig to be used
  * when instantiating a new Twig_Environment and Twig_Loader_Filesystem.
  *
  * @param array $config Optional configuration directives.
  *        Please see http://www.twig-project.org/book/03-Twig-for-Developers for all
  *        available configuration keys and their description.
  *        There are 4 settings that is set
  *        - `cache`: Path to /resources/tmp/cache/templates/ where compiled templates will be stored
  *        - `auto_reload`: If Environment is not production, templates will be reloaded once edited
  *        - `base_template_class`: Overriden to the Template adapter, be carefull with changing this
  *        - `autoescape`: Set to false because the way we inject content is with full html that should not be escaped
  * @return void
  * @todo Change hardcoded LITHIUM_APP_PATH to be dynamic
  */
 public function __construct(array $config = array())
 {
     $defaults = array('cache' => Twig::cachePath(), 'auto_reload' => !Environment::is('production'), 'autoescape' => false);
     parent::__construct($config + $defaults);
 }