public function construct(ConstructEvent $event)
 {
     // @codingStandardsIgnoreEnd
     // @codingStandardsIgnoreStart
     // CakePHP specific tags
     $event->getTwig()->addTokenParser(new TokenParser\Cell());
     $event->getTwig()->addTokenParser(new TokenParser\Element());
     // @codingStandardsIgnoreEnd
 }
Esempio n. 2
0
 /**
  * Constructor.
  *
  * @param Request      $request      Request.
  * @param Response     $response     Response.
  * @param EventManager $eventManager EventManager.
  * @param array        $viewOptions  View options.
  */
 public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
 {
     if ($eventManager === null) {
         $eventManager = EventManager::instance();
     }
     $this->eventManager = $eventManager;
     $this->twig = new \Twig_Environment($this->getLoader(), $this->resolveConfig());
     $this->eventManager->dispatch(ConstructEvent::create($this, $this->twig));
     parent::__construct($request, $response, $eventManager, $viewOptions);
     $this->_ext = self::EXT;
     $this->generateHelperList();
 }
Esempio n. 3
0
 /**
  * Constructor.
  *
  * @param Request      $request      Request.
  * @param Response     $response     Response.
  * @param EventManager $eventManager EventManager.
  * @param array        $viewOptions  View options.
  */
 public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
 {
     if ($eventManager === null) {
         $eventManager = EventManager::instance();
     }
     $this->eventManager = $eventManager;
     $this->twig = new \Twig_Environment($this->getLoader(), ['cache' => CACHE . 'twigView' . DS, 'charset' => strtolower(Configure::read('App.encoding')), 'auto_reload' => Configure::read('debug'), 'debug' => Configure::read('debug')]);
     $this->eventManager->dispatch(ConstructEvent::create($this, $this->twig));
     parent::__construct($request, $response, $eventManager, $viewOptions);
     $this->_ext = self::EXT;
     $this->generateHelperList();
 }
Esempio n. 4
0
 /**
  * Event handler.
  *
  * @param ConstructEvent $event Event.
  *
  * @return void
  */
 public function construct(ConstructEvent $event)
 {
     $profile = new \Twig_Profiler_Profile();
     $event->getTwig()->addExtension(new Extension\Profiler($profile));
     EventManager::instance()->dispatch(ProfileEvent::create($profile));
 }
Esempio n. 5
0
 public function construct(ConstructEvent $event)
 {
     // @codingStandardsIgnoreEnd
     // @codingStandardsIgnoreStart
     // Twig core extensions
     $event->getTwig()->addExtension(new \Twig_Extension_StringLoader());
     $event->getTwig()->addExtension(new \Twig_Extension_Debug());
     // CakePHP bridging extensions
     $event->getTwig()->addExtension(new Extension\I18n());
     $event->getTwig()->addExtension(new Extension\Time());
     $event->getTwig()->addExtension(new Extension\Basic());
     $event->getTwig()->addExtension(new Extension\Number());
     $event->getTwig()->addExtension(new Extension\Utils());
     $event->getTwig()->addExtension(new Extension\Arrays());
     $event->getTwig()->addExtension(new Extension\Strings());
     $event->getTwig()->addExtension(new Extension\Inflector());
     // Third party cache extension
     $cacheProvider = new Cache();
     $cacheStrategy = new LifetimeCacheStrategy($cacheProvider);
     $cacheExtension = new CacheExtension($cacheStrategy);
     $event->getTwig()->addExtension($cacheExtension);
     // @codingStandardsIgnoreEnd
 }