本文整理汇总了PHP中Service::getTemplateEngine方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::getTemplateEngine方法的具体用法?PHP Service::getTemplateEngine怎么用?PHP Service::getTemplateEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service::getTemplateEngine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareTwig
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());
}
示例2: addTwigGlobals
/**
* 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;
}
示例3: render
/**
* 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;
}
示例4: emailNotification
/**
* 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));
}