示例#1
0
文件: Attire.php 项目: ufhy/Attire
 /**
  * Prepend or append Twig Loader global path
  * 
  * @param string  $path      | Relative path
  * @param string  $namespace | Space name without the '@' symbol
  * @param boolean $prepend   | Enable prepend mode
  */
 public function add_path($path, $namespace = '__main__', $prepend = FALSE)
 {
     try {
         if (!$this->_loader instanceof Twig_Loader_Filesystem) {
             throw new Exception("Set the Twig_Loader as Filesystem.");
         }
         $prepend !== FALSE ? $this->_loader->prependPath($path, $namespace) : $this->_loader->addPath($path, $namespace);
     } catch (Exception $e) {
         show_error($e->getMessage(), 404, 'Attire::add_path()');
     }
     return $this;
 }
示例#2
0
 /**
  * Add global path
  *
  * Prepend or append Twig Loader global path
  * 
  * @param string  $path       Relative path
  * @param string  $namespace Space name without the '@'
  * @param boolean $prepend    Prepend method mode
  * 
  * @return self
  */
 public function add_path($path = '', $namespace = '__main__', $prepend = FALSE)
 {
     try {
         if (!is_a($this->_loader, 'Twig_Loader_Filesystem')) {
             throw new Exception('Loader not set correctly.');
         }
         # Checking if directory path exist
         $absolute_path = str_replace('//', '/', realpath(rtrim($path, '/') . '/'));
         if (!file_exists($path)) {
             throw new Exception("{$path} currently not exist.");
         }
     } catch (Exception $e) {
         $this->_show_error($e->getMessage());
     }
     # Prepend or append?
     $prepend !== FALSE ? $this->_loader->prependPath($absolute_path, $namespace) : $this->_loader->addPath($absolute_path, $namespace);
     return $this;
 }