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('*****@*****.**')->setTo($reviewer->getUser()->getEmail())->setBody($this->templating->render('email/assignReviewerEvent.html.twig', array('reviewer' => $reviewer))); $this->email->send($message); }
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; }
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); }
/** * @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)); }
/** * {@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)); }
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(); } }
/** * {@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(); }
/** * 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; }
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()]); }
/** * @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']); } }
/** * 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; }
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))); }
/** * @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])); }
/** * 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; }
/** * 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); }
/** * 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 ); }
public function render(CantigaController $controller, Request $request, Workspace $workspace, Project $project = null) { $text = $this->textRepository->getTextOrFalse('cantiga:dashboard:' . $workspace->getKey(), $request, $project); if (false === $text) { return ''; } return $this->templating->render('CantigaCoreBundle:AppText:dashboard-element.html.twig', ['text' => $text]); }
/** * {@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; }
/** * 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(); }
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)); }
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)); }
public function render(CantigaController $controller, Request $request, Area $area) { $data = $area->getCustomData(); if (!empty($data['positionLat']) && !empty($data['positionLng'])) { return $this->templating->render('WioEdkBundle:Extension:area-information-map.html.twig', ['positionLat' => $data['positionLat'], 'positionLng' => $data['positionLng']]); } return ''; }
public function render(CantigaController $controller, Request $request, Workspace $workspace, Project $project = null) { if ($controller->getProjectSettings()->get(CoreSettings::DASHOBARD_SHOW_REQUESTS)->getValue()) { $this->repository->setActiveProject($project); return $this->templating->render('CantigaCoreBundle:Project:recent-area-requests.html.twig', ['requests' => $this->repository->getRecentRequests(5)]); } return ''; }
/** * Payment execution. * * @return Response */ public function executeAction() { /** * The execute action will generate the Paypal web * checkout form before redirecting. */ $formView = $this->redsysManager->processPayment(); return new Response($this->templatingEngine->render('PaypalWebCheckoutBundle:Paypal:process.html.twig', ['paypal_form' => $formView])); }
public function sendAttributeSupportMail() { $user = $this->userService->getUser(); $body = $this->templateEngine->render('OpenConextProfileBundle:AttributeSupport:email.html.twig', ['attributes' => $user->getAttributes()]); /** @var Message $message */ $message = $this->mailer->createMessage(); $message->setFrom($this->mailFrom->getEmailAddress())->setTo($this->mailTo->getEmailAddress())->setSubject(sprintf('Personal debug info of %s', $user->getId()))->setBody($body, 'text/html', 'utf-8'); $this->mailer->send($message); }
/** * Payment execution. * * @return Response */ public function executeAction() { /** * The execute action will generate the Redsys * checkout form before redirecting */ $formView = $this->redsysManager->processPayment(); return new Response($this->templatingEngine->render('RedsysBundle:Redsys:process.html.twig', ['redsys_form' => $formView])); }
/** * @param Connection $connection */ public function sendConnectionCreatedEmail(Connection $connection) { $emailData = [['recipient' => $connection->getFluentSpeaker(), 'partner' => $connection->getLearner()], ['recipient' => $connection->getLearner(), 'partner' => $connection->getFluentSpeaker()]]; foreach ($emailData as $data) { $parameters = ['connection' => $connection, 'recipient' => $data['recipient'], 'partner' => $data['partner']]; $message = \Swift_Message::newInstance()->setSubject('Fikakompis/ Musikkompis från Kompisbyrån')->setFrom('*****@*****.**')->setReplyTo('*****@*****.**')->setTo($data['recipient']->getEmail(), $data['recipient']->getName())->setBody($this->templating->render('email/connectionCreated.html.twig', $parameters), 'text/html')->addPart($this->templating->render('email/connectionCreated.txt.twig', $parameters), 'text/plain'); $this->mailer->send($message); } }
/** * {@inheritdoc} */ public function render(ReportInterface $report, Data $data) { if (null !== $data->getData()) { $data = array('report' => $report, 'values' => $data->getData(), 'labels' => $data->getLabels(), 'fields' => array_keys($data->getData())); $rendererConfiguration = $report->getRendererConfiguration(); return $this->templating->render($rendererConfiguration["template"], array('data' => $data, 'configuration' => $rendererConfiguration)); } return $this->templating->render("SyliusReportBundle::noDataTemplate.html.twig", array('report' => $report)); }
/** * @return Metadata */ public function generate() { $metadata = $this->getMetadata(); $keyPair = $this->buildKeyPairFrom($this->metadataConfiguration); $metadata->document = SAML2_DOMDocumentFactory::create(); $metadata->document->loadXML($this->templateEngine->render('SurfnetSamlBundle:Metadata:metadata.xml.twig', ['metadata' => $metadata])); $this->signingService->sign($metadata, $keyPair); return $metadata; }
public function export(Portfolio $portfolio, $format) { if (!in_array($format, $this->availableFormats)) { throw new \InvalidArgumentException('Unknown format.'); } return $this->templatingEngine->render(sprintf('IcapPortfolioBundle:export:export.%s.twig', $format), array('portfolio' => $portfolio)); }