public function __construct(RequestInterface $request, ResponseInterface $response) { $this->request = $request; $this->response = $response; $event = Dispatcher::getInstance()->triggerEvent(new Event('CommandConstructor', $this)); if ($event->isCancelled()) { $response->flush(); exit; } }
public function render(RequestInterface $request, ResponseInterface $response) { ob_start(); $uri = Bootstrap::getPathView() . "/{$this->template}.phtml"; if (file_exists($uri) === false) { throw new \Exception("File not found " . $uri); } include_once $uri; $data = ob_get_clean(); $response->write($data); }
public function render(RequestInterface $request, ResponseInterface $response) { $timing = microtime(true); $this->assign('action', $request->getParameter('action')); $this->assign('controller', $request->getParameter('controller')); $loader = new Twig_Loader_Filesystem(Bootstrap::getPathView()); $twig = new Twig_Environment($loader, array('debug' => true, 'cache' => Bootstrap::getPathCache(), 'auto_reload' => true, 'optimizations' => -1)); $twig->addExtension(new \Twig_Extension_Debug()); $data = $twig->render("{$this->template}.twig", $this->vars); $response->addHeader('X-OPF-TWIG-TIMING', microtime(true) - $timing); $response->write($data); }