本文整理汇总了PHP中Symfony\Component\Templating\EngineInterface类的典型用法代码示例。如果您正苦于以下问题:PHP EngineInterface类的具体用法?PHP EngineInterface怎么用?PHP EngineInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EngineInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function it_can_be_transformed(EngineInterface $templating, FilterChainInterface $filterChain, MailUserInterface $recipient1, MailUserInterface $recipient2, Attachment $attachment)
{
$html = '<html><head></head><body>Test</body></html>';
$templating->render(Argument::type('string'), Argument::type('array'))->willReturn($html);
$filterChain->apply(Argument::type('string'), Argument::any())->willReturn($html);
$recipient1->getFullName()->willReturn('Test recipient 1');
$recipient1->getEmail()->willReturn('recipient1@test.com');
$recipient2->getFullName()->willReturn('Test recipient 2');
$recipient2->getEmail()->willReturn('recipient2@test.com');
$attachmentFileName = 'test.txt';
$attachment->getData()->willReturn('test');
$attachment->getFilename()->willReturn($attachmentFileName);
$attachment->getContentType()->willReturn('text');
$this->addRecipients([$recipient1, $recipient2]);
$this->addBccRecipients([$recipient1, $recipient2]);
$this->addAttachment($attachment);
$message = $this->transform($templating, $filterChain, array(array('view' => 'default', 'contentType' => 'text/html')));
$message->shouldHaveType('\\Swift_Message');
$message->getSubject()->shouldBeLike(self::SUBJECT);
$message->getBody()->shouldBeLike($html);
$message->getFrom()->shouldBeLike(array(self::SENDER_EMAIL => self::SENDER_NAME));
$message->getTo()->shouldHaveCount(2);
$message->getBcc()->shouldHaveCount(2);
$message->getChildren()->shouldHaveCount(1);
// 1 attachment
$attachment = $message->getChildren()[0];
$attachment->shouldHaveType('Swift_Mime_Attachment');
$attachment->getFileName()->shouldBeLike($attachmentFileName);
}
示例2: setUp
public function setUp()
{
$this->configResolver = $this->getMockBuilder('\\eZ\\Publish\\Core\\MVC\\ConfigResolverInterface')->getMock();
$this->configResolver->method('getParameter')->willReturn('Tests/fixtures/template_module.js');
$this->templating = $this->getMockBuilder('\\Symfony\\Component\\Templating\\EngineInterface')->getMock();
$this->templating->method('render')->willReturn('template');
$this->comboLoader = new ComboLoader($this->configResolver, $this->templating, '/yui/', 'Tests/fixtures');
}
示例3: 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);
}
示例4: 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;
}
示例5: 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));
}
示例6: 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);
}
示例7: 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']);
}
}
示例8: 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;
}
示例9: 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;
}
示例10: onKernelView
/**
* @param GetResponseForControllerResultEvent $event
*/
public function onKernelView(GetResponseForControllerResultEvent $event)
{
$request = $event->getRequest();
$nodeTranslation = $request->attributes->get('_nodeTranslation');
if ($nodeTranslation) {
$entity = $request->attributes->get('_entity');
$url = $request->attributes->get('url');
$nodeMenu = $request->attributes->get('_nodeMenu');
$parameters = $request->attributes->get('_renderContext');
if ($request->get('preview') == true) {
$version = $request->get('version');
if (!empty($version) && is_numeric($version)) {
$nodeVersion = $this->em->getRepository('KunstmaanNodeBundle:NodeVersion')->find($version);
if (!is_null($nodeVersion)) {
$entity = $nodeVersion->getRef($this->em);
}
}
}
$renderContext = array('nodetranslation' => $nodeTranslation, 'slug' => $url, 'page' => $entity, 'resource' => $entity, 'nodemenu' => $nodeMenu);
if (is_array($parameters) || $parameters instanceof \ArrayObject) {
$parameters = array_merge($renderContext, (array) $parameters);
} else {
$parameters = $renderContext;
}
// Sent the response here, another option is to let the symfony kernel.view listener handle it
$event->setResponse($this->templating->renderResponse($entity->getDefaultView(), $parameters));
}
}
示例11: 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);
}
示例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: 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()]);
}
示例15: 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();
}
}