php Symfony-Component-Templating-EngineInterface类(方法)实例源码

下面列出了php Symfony-Component-Templating-EngineInterface 类(方法)源码代码实例,从而了解它的用法。

作者:tomazahli    项目:symfony-mailer-bundl   
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);
 }

作者:yed3    项目:PlatformUIBundl   
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');
 }

作者:aulasoftwarelibr    项目:fastconfe   
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);
 }

作者:alterph    项目:component   
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;
 }

作者:it-blaste    项目:page-layout-bundl   
/**
  * @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));
 }

作者:aw-ryo-matsuy    项目:aw-even   
/**
  * 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);
 }

作者:rafrs    项目:form-extra-bundl   
/**
  * @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']);
     }
 }

作者:emodri    项目:LegacyBridg   
/**
  * 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;
 }

作者:TheDevilOnLin    项目:OrkestraPdfBundl   
/**
  * 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;
 }

作者:kustov-vitali    项目:KunstmaanBundlesCM   
/**
  * @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));
     }
 }

作者:enhav    项目:enhav   
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);
 }

作者:bestfor    项目:diaborg   
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)));
 }

作者:OpenConex    项目:OpenConext-profil   
/**
  * @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]));
 }

作者:zyxis    项目:cantig   
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()]);
 }

作者:ehoug    项目:emailerrors-bundl   
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();
     }
 }

作者:ezsystemstrainin    项目:ez54trainin   
/**
     * Renders the template with provided options.
     * "template" option allows to override the default template for rendering.
     *
     * @param array $options
     * @return string
     */
    protected function doRender( array $options )
    {
        $template = isset( $options['template'] ) ? $options['template'] : $this->getDefaultTemplate();
        unset( $options['template'] );

        return $this->templateEngine->render( $template, $options );
    }

作者:Valentinlaz    项目:symfony-angular-see   
/**
  * Flushes messages
  */
 public function flush()
 {
     foreach ($this->pendingEmails as $email) {
         $message = \Swift_Message::newInstance()->setSubject($this->translator->trans($email->getSubject()))->setFrom($this->from)->setTo($email->getSendTo())->setBody($this->templating->render($email->getTemplate(), $email->getData()));
         $this->mailer->send($message, $failedRecipients);
     }
     $this->clear();
 }

作者:karous    项目:SonataBlockBundl   
/**
  * {@inheritdoc}
  */
 public function render(\Exception $exception, BlockInterface $block, Response $response = null)
 {
     $parameters = array('exception' => $exception, 'block' => $block);
     $content = $this->templating->render($this->template, $parameters);
     $response = $response ?: new Response();
     $response->setContent($content);
     return $response;
 }

作者:nathix8    项目:bcp-websit   
public function handleCookieConsent(FilterResponseEvent $event)
 {
     if (!$event->isMasterRequest() || $event->getRequest()->cookies->has($this->cookieName)) {
         return;
     }
     $response = $event->getResponse();
     $response->setContent($response->getContent() . $this->templating->render($this->cookieTemplate));
 }

作者:enhav    项目:enhav   
public function render($type = 'search', $entities = null, $fields = null)
 {
     if ($this->templateEngine === null) {
         $this->templateEngine = $this->container->get('templating');
     }
     $template = $this->container->getParameter('enhavo_search.' . $type . '.template');
     return $this->templateEngine->render($template, array('type' => $type, 'entities' => $entities, 'fields' => $fields));
 }


问题


面经


文章

微信
公众号

扫码关注公众号