本文整理汇总了PHP中Symfony\Component\Templating\EngineInterface::render方法的典型用法代码示例。如果您正苦于以下问题:PHP EngineInterface::render方法的具体用法?PHP EngineInterface::render怎么用?PHP EngineInterface::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Templating\EngineInterface
的用法示例。
在下文中一共展示了EngineInterface::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onReviewerSubmitted
public function onReviewerSubmitted(AssignReviewerEvent $event)
{
$reviewer = $event->getReviewer();
$this->logger->debug('FASTCONFER: Asignado revisores a artículo: ' . $reviewer->getArticle()->getTitle());
$message = $this->email->createMessage()->setSubject('You have Completed Registration!')->setFrom('send@example.com')->setTo($reviewer->getUser()->getEmail())->setBody($this->templating->render('email/assignReviewerEvent.html.twig', array('reviewer' => $reviewer)));
$this->email->send($message);
}
示例2: getPdfContent
public function getPdfContent($name, array $data = array())
{
$this->init();
$tplFile = sprintf('%s:%s.pdf.twig', $this->options['tplShortDirectory'], $name);
$htmlContent = $this->twig->render($tplFile, $data);
$pdfContent = $this->snappy->getOutputFromHtml($htmlContent);
return $pdfContent;
}
示例3: sendConfirmMail
private function sendConfirmMail(Configuration $configuration, ContactInterface $model)
{
$text = $this->templating->render($configuration->getConfirmTemplate(), ['data' => $model]);
$subject = $this->translator->trans($configuration->getSubject(), [], $configuration->getTranslationDomain());
$message = \Swift_Message::newInstance()->setSubject($subject)->setFrom($configuration->getFrom())->setTo($model->getEmail())->setBody($text, 'text/html');
$this->mailer->send($message);
}
示例4: render
/**
* @return string
* @throws \Exception
*/
public function render()
{
$this->checkLayoutData(__FUNCTION__);
$this->passWidgetsToRenderer($this->layout_data);
$rows = $this->convertGridstackToBootstrap($this->getLayoutData());
return $this->templating->render($this->templates['front_layout'], array('rows' => $rows, 'renderer' => $this->widget_renderer));
}
示例5: export
/**
* {@inheritdoc}
*/
public function export($webspaceKey, $locale, $output, $format = '1.2.xliff', $uuid = null, $nodes = null, $ignoredNodes = null)
{
if (!$webspaceKey || !$locale) {
throw new \Exception(sprintf('Invalid parameters for export "%s (%s)"', $webspaceKey, $locale));
}
return $this->templating->render($this->getTemplate($format), $this->getExportData($webspaceKey, $locale, $output, $format, $uuid, $nodes, $ignoredNodes));
}
示例6: sendMail
public function sendMail(\Exception $exception, Request $request, array $context, $needToFlush)
{
if (!$exception instanceof FlattenException) {
$exception = FlattenException::create($exception);
}
if (!$this->_hasInitialized) {
$this->_initialize();
}
$params = array('exception' => $exception, 'request' => $request, 'context' => $context, 'status_text' => Response::$statusTexts[$exception->getStatusCode()]);
$preMailEvent = new GenericEvent($params, array('shouldSend' => true));
$this->_eventDispatcher->dispatch('ehough.bundle.emailErrors.preMail', $preMailEvent);
if (!$preMailEvent->getArgument('shouldSend')) {
//mail was cancelled
return;
}
$body = $this->_templatingEngine->render('EhoughEmailErrorsBundle::mail.html.twig', $params);
$subject = '[' . $request->headers->get('host') . '] Error ' . $exception->getStatusCode() . ': ' . $exception->getMessage();
if (function_exists('mb_substr')) {
$subject = mb_substr($subject, 0, 255);
} else {
$subject = substr($subject, 0, 255);
}
$mail = \Swift_Message::newInstance()->setSubject($subject)->setFrom($this->_fromAddress)->setTo($this->_toAddress)->setContentType('text/html')->setBody($body);
$this->_mailer->send($mail);
if ($needToFlush) {
$this->_flushEmailer();
}
}
示例7: render
/**
* {@inheritdoc}
*/
public function render($name, array $parameters = array())
{
if ($this->request->isXmlHttpRequest()) {
return $this->engine->render($name, $parameters);
}
if (!$this->admin->inAdmin() || $this->isRender || in_array($name, ['GloryAdminBundle:Security:login.html.twig'])) {
return $this->engine->render($name, $parameters);
}
$this->isRender = true;
$layoutName = 'GloryAdminBundle::layout.html.twig';
$template = $this->load($name);
if (in_array($layoutName, $this->getTemplates($template))) {
return $this->engine->render($name, $parameters);
}
$layout = $this->load($layoutName);
$blocks = $this->getBlocks($template, $parameters);
// $blocks = [];
// foreach (['title', 'stylesheets', 'javascripts', 'content'] as $name) {
// if (false !== $block = $this->getBlock($template, $name)) {
// $blocks[$name] = $block;
// }
// }
ob_start();
try {
$layout->display($parameters, $blocks);
} catch (\Exception $e) {
ob_end_clean();
throw $e;
}
return ob_get_clean();
}
示例8: getIndex
/**
* Get the index file as a string
*
* @param string $environment
* @param string $version
* @return string
*
* @throws \Exception when unable to access the version
*/
public function getIndex($environment, $version = null)
{
$fileName = $environment . '-' . self::API_VERSION . '/index.json';
if ($version) {
$fileName .= ':' . $version;
}
$content = $this->getIndexFromAWS($fileName);
$json = json_decode($content);
$metas = array_map(function ($obj) {
return ['name' => $obj->name, 'content' => $obj->content];
}, $json->meta);
$links = array_map(function ($obj) {
return ['rel' => $obj->rel, 'href' => $obj->href];
}, $json->link);
$scripts = array_map(function ($obj) {
return $obj->src;
}, $json->script);
$options = ['metas' => $metas, 'links' => $links, 'scripts' => $scripts];
$template = $this->getTemplatePath();
$body = $this->templatingEngine->render($template, $options);
if (!$body) {
throw new Exception('Failed to create index file for version ' . $version);
}
return $body;
}
示例9: render
public function render(CantigaController $controller, Request $request, Workspace $workspace, Project $project = null)
{
$rootEntity = $controller->getMembership()->getItem();
$this->repository->setRootEntity($rootEntity);
$this->settingsRepository->setRootEntity($rootEntity);
return $this->templating->render('WioEdkBundle:Extension:route-summary.html.twig', ['routeNum' => $this->repository->countRoutes(), 'participantNum' => $this->settingsRepository->countParticipants()]);
}
示例10: finishView
/**
* @inheritdoc
*/
public function finishView(FormView $view, FormInterface $form, array $options)
{
/** @var ChoiceView $choice */
foreach ($view->vars['choices'] as $choice) {
if ($options['select2_template_result']) {
$object = $choice->value;
if ($this->doctrine && $options['class']) {
$object = $this->doctrine->getRepository($options['class'])->find($object);
}
if (is_string($options['select2_template_result'])) {
$choice->attr['data-template-result'] = $this->templating->render($options['select2_template_result'], ['choice' => $choice, 'object' => $object]);
} else {
$choice->attr['data-template-result'] = call_user_func_array($options['select2_template_result'], [$choice, $object]);
}
}
if ($options['select2_template_selection']) {
$object = $choice->value;
if ($this->doctrine && $options['class']) {
$object = $this->doctrine->getRepository($options['class'])->find($object);
}
if (is_string($options['select2_template_selection'])) {
$choice->attr['data-template-selection'] = $this->templating->render($options['select2_template_selection'], ['choice' => $choice, 'object' => $object]);
} else {
$choice->attr['data-template-selection'] = call_user_func_array($options['select2_template_selection'], [$choice, $object]);
}
}
}
if ($options['select2'] === true) {
$options['select2_options'] = array_merge($this->select2DefaultOptions, $options['select2_options']);
$view->vars['select2_options'] = json_encode($options['select2_options']);
}
}
示例11: websiteToolbarAction
/**
* Renders the legacy website toolbar template.
*
* If the logged in user doesn't have the required permission, an empty response is returned
*
* @param mixed $locationId
* @param Request $request
*
* @return Response
*/
public function websiteToolbarAction($locationId, Request $request)
{
$response = new Response();
if (isset($this->csrfProvider)) {
$parameters['form_token'] = $this->csrfProvider->generateCsrfToken('legacy');
}
if ($this->previewHelper->isPreviewActive()) {
$template = 'design:parts/website_toolbar_versionview.tpl';
$previewedContent = $authValueObject = $this->previewHelper->getPreviewedContent();
$previewedVersionInfo = $previewedContent->versionInfo;
$parameters = array('object' => $previewedContent, 'version' => $previewedVersionInfo, 'language' => $previewedVersionInfo->initialLanguageCode, 'is_creator' => $previewedVersionInfo->creatorId === $this->getRepository()->getCurrentUser()->id);
} elseif ($locationId === null) {
return $response;
} else {
$authValueObject = $this->loadContentByLocationId($locationId);
$template = 'design:parts/website_toolbar.tpl';
$parameters = array('current_node_id' => $locationId, 'redirect_uri' => $request->attributes->get('semanticPathinfo'));
}
$authorizationAttribute = new AuthorizationAttribute('websitetoolbar', 'use', array('valueObject' => $authValueObject));
if (!$this->authChecker->isGranted($authorizationAttribute)) {
return $response;
}
$response->setContent($this->legacyTemplateEngine->render($template, $parameters));
return $response;
}
示例12: listAction
public function listAction()
{
$data = $this->repository->getList();
$entries = array();
$dayId = 0;
foreach ($data as $entry) {
$timestamp = $entry->getTimestamp()->getTimestamp();
$dateTime = new \DateTime();
$dateTime->setTimestamp($timestamp);
$dateTime->setTime(0, 0);
$currentDay = $dateTime->getTimestamp();
if (!isset($entries[$currentDay])) {
//init day
$entries[$currentDay] = array();
$entries[$currentDay]['entries'] = array();
$entries[$currentDay]['id'] = $dayId++;
$entries[$currentDay]['date'] = date('l, d. F', $currentDay);
$entries[$currentDay]['grapharray'] = "{}";
}
$entries[$currentDay]['entries'][] = array("id" => $entry->getId(), "timestamp" => $timestamp, "time" => date('H:i', $timestamp), "value" => $entry->getValue(), "insulin" => $entry->getInsulin(), "BE" => $entry->getBE(), "key" => $entry->getTimestamp());
}
$entries = $this->augmentGraphData($entries);
$entries = array_reverse($entries);
return new Response($this->templating->render('Diaborg3Bundle:List:list.html.twig', array("entries" => $entries)));
}
示例13: overviewAction
/**
* @return Response
*/
public function overviewAction()
{
$this->guard->userIsLoggedIn();
$this->logger->notice('Showing My Profile page');
$user = $this->userService->getUser();
return new Response($this->templateEngine->render('OpenConextProfileBundle:MyProfile:overview.html.twig', ['user' => $user]));
}
示例14: renderPdf
/**
* Renders a PDF using the Templating engine
*
* @param string $name The name of the template
* @param array $parameters An array of parameters to pass to the template
* @param array $options Options to be used when creating the new PDF
*
* @return \TCPDF
*/
public function renderPdf($name, array $parameters = array(), array $options = array())
{
$html = $this->templatingEngine->render($name, $parameters);
$pdf = $this->pdfFactory->create($options);
$pdf->writeHTML($html);
return $pdf;
}
示例15: breadcrumbs
/**
* Returns the HTML for the namespace breadcrumbs
*
* @param array $options The user-supplied options from the view
* @return string A HTML string
*/
public function breadcrumbs(array $options = array())
{
$options = $this->resolveOptions($options);
// Assign namespace breadcrumbs
$options["breadcrumbs"] = $this->breadcrumbs->getNamespaceBreadcrumbs($options['namespace']);
return $this->templating->render($options["viewTemplate"], $options);
}