コード例 #1
0
 /**
  * Initialize the CaravanController class
  */
 public function init()
 {
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     if (file_exists(_TWIG_AUTOLOADER_)) {
         try {
             require_once _TWIG_AUTOLOADER_;
             Twig_Autoloader::register();
             $loader = new Twig_Loader_Filesystem(array(_DEPENDENCIES_DIR_, _CARAVANS_VIEWS_));
             $this->twig = new Twig_Environment($loader, array('cache' => _TWIG_CACHE_));
         } catch (Exception $e) {
             throw new Exception('Le fichier de démarrage Twig ne peut pas s\'executer!');
         }
     } else {
         throw new Exception('Il n\'existe pas le fichier de démarrage Twig à cet emplacement "' . _TWIG_AUTOLOADER_ . '"!');
     }
 }