本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::render方法的典型用法代码示例。如果您正苦于以下问题:PHP EngineInterface::render方法的具体用法?PHP EngineInterface::render怎么用?PHP EngineInterface::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Templating\EngineInterface
的用法示例。
在下文中一共展示了EngineInterface::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onKernelException
/**
* Renders the defined {@see ExceptionListener::$errorTemplate}, which has been defined via YAML
* settings, on exception.
*
* Note, that the function is only called, if the *debug value* is set or *error pages* are
* enabled via Parameter *stvd.error_page.enabled*.
*
* @param GetResponseForExceptionEvent $event
*/
public function onKernelException(GetResponseForExceptionEvent $event)
{
// don't do anything if it's not the master request
if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
return;
}
// You get the exception object from the received event
$exception = $event->getException();
// Customize your response object to display the exception details
$response = new Response();
// set response content
$response->setContent($this->templating->render($this->errorTemplate, array('exception' => $exception)));
// HttpExceptionInterface is a special type of exception that
// holds status code and header details
if ($exception instanceof HttpExceptionInterface) {
$response->setStatusCode($exception->getStatusCode());
$response->headers->replace($exception->getHeaders());
} else {
// If the exception's status code is not valid, set it to *500*. If it's valid, the
// status code will be transferred to the response.
if ($exception->getCode()) {
$response->setStatusCode($exception->getCode());
} else {
$response->setStatusCode(500);
}
}
// Send the modified response object to the event
$event->setResponse($response);
}
示例2: sendResettingEmailMessage
/**
* {@inheritDoc}
*/
public function sendResettingEmailMessage(UserInterface $user)
{
$template = $this->parameters['resetting_password.template'];
$url = $this->router->generate('fos_user_resetting_reset', array('token' => $user->getConfirmationToken()), true);
$rendered = $this->templating->render($template, array('confirmationUrl' => $url, 'user' => $user));
$this->sendEmailMessage($rendered, $user->getEmail());
}
示例3: onKernelResponse
public function onKernelResponse(FilterResponseEvent $event)
{
return;
// disabled theming for the time being while it gets refactored.
if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
$response = $event->getResponse();
if ($request->isXmlHttpRequest()) {
return;
}
if ($response instanceof RedirectResponse || $response instanceof PlainResponse || $response instanceof AbstractBaseResponse) {
// dont theme redirects, plain responses or Ajax responses
return;
}
$request = $event->getRequest();
// if (!$request->isXmlHttpRequest()
// && strpos($response->getContent(), '</body>') === false
// && !$response->isRedirection()
// && 'html' === $request->getRequestFormat()
// && (($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) || !$response->headers->has('Content-Type') )) {
// $content = $this->templating->render($this->activeTheme.'::master.html.twig', array('maincontent' => $response->getContent()));
// $response->setContent('ddd'.$content);
// }
$content = $this->templating->render($this->activeTheme . '::master.html.twig', array('maincontent' => $response->getContent()));
$response->setContent($content);
}
}
示例4: render
public function render()
{
if ($this->templateEngine === null) {
$this->templateEngine = $this->container->get('templating');
}
$menus = $this->container->get('enhavo_app.menu_loader')->getMenu();
return $this->templateEngine->render($this->template, array('menus' => $menus));
}
示例5: writeEntity
/**
* @param object $entity
* @param string $template
* @throws \RuntimeException
*/
public function writeEntity($entity, $template)
{
if (!$this->fp) {
throw new \RuntimeException('Writer is not open');
}
$xml = $this->templating->render($template, ['entity' => $entity]);
fwrite($this->fp, $xml);
}
示例6: generateMail
/**
* @param $test
* @return \Swift_Mime_MimePart
* @throws \TijsVerkoyen\CssToInlineStyles\Exception
*/
private function generateMail(Test $test, $template, $to)
{
$html = $this->template->render($template, array("test" => $test));
$css = file_get_contents($this->assetsHelper->getUrl('bundles/corrigeatonmailer/css/main.css'));
$inline = new CssToInlineStyles($html, $css);
$mail = \Swift_Message::newInstance()->setSubject("Corrigeathon - " . $test->getName())->setFrom($this->emailSend)->setTo($to)->setBcc("corrigeathon@etud.insa-toulouse.fr")->setBody($inline->convert(), 'text/html');
return $mail;
}
示例7: sendContactEmail
public function sendContactEmail(Messages $message)
{
// Envoie un remerciement à l'utilisateur
$email_contact = \Swift_Message::newInstance()->setSubject('Votre message a bien été reçu !')->setFrom('vleprince123@gmail.com')->setTo($message->getEmail())->setContentType('text/html')->setBody($this->templating->render('default/email.html.twig', array('nom' => $message->getNom(), 'prenom' => $message->getPrenom(), 'email' => $message->getEmail())));
$this->swiftmailer->send($email_contact);
// Envoie un message à Gustavo pour le prévenir qu'il vient d'être contacté
$email_contact = \Swift_Message::newInstance()->setSubject('Gustavo, vous avez reçu un message !')->setTo('vleprince123@gmail.com')->setFrom($message->getEmail())->setContentType('text/html')->setBody($this->templating->render('default/email_contact_gustavo.html.twig', array('message' => $message)));
$this->swiftmailer->send($email_contact);
}
示例8: render
/**
* {@inheritdoc}
*/
public function render($object, $format, array $context = [])
{
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$params = array_merge($context, ['product' => $object, 'groupedAttributes' => $this->getGroupedAttributes($object, $context['locale']), 'imageAttributes' => $this->getImageAttributes($object, $context['locale'])]);
$resolver->resolve($params);
$params['uploadDir'] = $this->uploadDirectory . DIRECTORY_SEPARATOR;
return $this->pdfBuilder->buildPdfOutput($this->templating->render($this->template, $params));
}
示例9: onKernelResponse
public function onKernelResponse(FilterResponseEvent $event)
{
if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
$response = $event->getResponse();
$request = $event->getRequest();
if (!$request->isXmlHttpRequest() && strpos($response->getContent(), '</body>') === false && !$response->isRedirection() && 'html' === $request->getRequestFormat() && ($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html') || !$response->headers->has('Content-Type'))) {
$content = $this->templating->render($this->activeTheme . '::base.html.twig', array('content' => $response->getContent()));
$response->setContent($content);
}
}
}
示例10: notify
/**
* Create and send mail notification.
*
* @param array $vars Variables to use when rendering mail body.
* @return MailNotification $this Fluent interface.
*/
public function notify(array $vars = array())
{
$message = \Swift_Message::newInstance()->setSubject($this->settings['subject'])->setFrom($this->settings['from'])->setTo($this->settings['to'])->setCc($this->settings['cc'])->setBcc($this->settings['bcc'])->setBody($this->templateEngine->render($this->settings['template'], $vars), 'text/html');
try {
$this->mailer->send($message);
$this->getLogger()->notice('Mail notification successfully sent.', array_merge($this->settings, array('body' => $message->getBody())));
} catch (\Exception $e) {
$this->getLogger()->error('Could not send email notification.', array_merge($this->settings, array('body' => $message->getBody())));
}
return $this;
}
示例11: postFormSubmit
/**
* This method is called right after the post is stored in the database during the Form submit.
* It checks whether the form has a notification email set, and if so, it sends out a notification
* email.
*
* @param FormSubmitEvent $event
*/
public function postFormSubmit(FormSubmitEvent $event)
{
$post = $event->getPost();
$form = $post->getForm();
if (!$form->getNotificationEmail()) {
return;
}
$body = $this->templating->render('OpiferFormBundle:Email:notification.html.twig', ['post' => $post]);
$message = \Swift_Message::newInstance()->setSender($this->sender)->setFrom($this->sender)->setTo($form->getNotificationEmail())->setSubject($form->getName())->setBody($body);
$this->mailer->send($message);
}
示例12: onSuccess
/**
* "Success" form handler
*
* @param RFPRequest $rfpRequest
*/
protected function onSuccess(RFPRequest $rfpRequest)
{
$status = $this->form->get('status')->getData();
$noteMessage = trim($this->form->get('note')->getData());
$rfpRequest->setStatus($status);
if (!empty($noteMessage)) {
$note = new Note();
$note->setTarget($rfpRequest)->setMessage(htmlspecialchars_decode($this->templating->render('OroB2BRFPBundle:Request:note.html.twig', ['status' => $status->getLabel(), 'note' => $noteMessage])));
$this->manager->persist($note);
}
$this->manager->flush();
}
示例13: searchAction
/**
* Search method.
*
* @param Request $request Current request to fetch info from.
*
* @return Response
*/
public function searchAction(Request $request)
{
$query = $request->get($this->options['query_param_name'], '');
$page = $request->get($this->options['page_param_name'], 1);
if (empty($query)) {
return new Response($this->templating->render($this->options['search_template'], array('query' => '', 'search_results' => array(), 'options' => $this->options['template_options'], 'estimated' => 0)));
}
$pager = $this->searchFactory->getPagerfanta($query, $request->getLocale());
$pager->setCurrentPage($page);
$results = $pager->getCurrentPageResults();
return new Response($this->templating->render($this->options['search_template'], array('query' => $query, 'pager' => $pager, 'search_results' => $results, 'estimated' => $pager->getNbResults(), 'options' => $this->options['template_options'])));
}
示例14: onKernelException
/**
* Manage kernel exception
* @param GetResponseForExceptionEvent $event
*
* @return GetResponseForExceptionEvent
*/
public function onKernelException(GetResponseForExceptionEvent $event)
{
$exception = $event->getException();
$response = new Response();
if ($exception instanceof HttpExceptionInterface) {
$response->setStatusCode($exception->getStatusCode());
$response->headers->replace($exception->getHeaders());
} else {
$response->setStatusCode(500);
}
$content = $this->templating->render('PimEnrichBundle:Error:base.html.twig', ['exception' => $exception, 'status_code' => $response->getStatusCode()]);
$response->setContent($content);
$event->setResponse($response);
}
示例15: renderJsTranslationContent
/**
* Combines JSON with js translation and renders js-resource
*
* @param array $domains
* @param string $locale
* @param bool $debug
* @return string
*/
public function renderJsTranslationContent(array $domains, $locale, $debug = false)
{
$domainsTranslations = $this->translator->getTranslations($domains, $locale);
$result = ['locale' => $locale, 'defaultDomains' => $domains, 'messages' => []];
if ($debug) {
$result['debug'] = true;
}
foreach ($domainsTranslations as $domain => $translations) {
$result['messages'] += array_combine(array_map(function ($id) use($domain) {
return sprintf('%s:%s', $domain, $id);
}, array_keys($translations)), array_values($translations));
}
return $this->templating->render($this->template, ['json' => $result]);
}