protected function prepareTwig() { $groups = Group::getGroups($this->getMe()->getId()); Service::getTemplateEngine()->addGlobal("groups", $groups); $creator = new MessageSearchFormCreator(); $searchForm = $creator->create(); Service::getTemplateEngine()->addGlobal("searchForm", $searchForm->createView()); }
/** * Prepare the twig global variables */ private function addTwigGlobals() { if ($this->twigReady) { return; } $request = $this->getRequest(); // Add global variables to the twig templates $twig = Service::getTemplateEngine(); $twig->addGlobal("me", $this->getMe()); $twig->addGlobal("model", new ModelFetcher()); $twig->addGlobal("request", $request); $twig->addGlobal("session", $request->getSession()); $twig->addGlobal("app", new AppGlobal($this->parent, $this->container)); $this->prepareTwig(); $this->twigReady = true; }
/** * Renders a view * @param string $view The view name * @param array $parameters An array of parameters to pass to the view * @return string The rendered view */ protected function render($view, $parameters = array()) { Debug::startStopwatch('view.render'); $template = Service::getTemplateEngine(); $ret = $template->render($view, $parameters); Debug::finishStopwatch('view.render'); return $ret; }
/** * Notify the user about a notification by e- * @param \Notification $notification The notification that will be mailed */ public function emailNotification(\Notification $notification) { $text = \Service::getTemplateEngine()->render('Notification/item.html.twig', array('notification' => $notification)); return $this->sendEmails(trim(strip_tags($text)), array($notification->getReceiver()->getId()), 'notification', array('notification' => $notification, 'text' => $text)); }