本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Templating\EngineInterface类的典型用法代码示例。如果您正苦于以下问题:PHP EngineInterface类的具体用法?PHP EngineInterface怎么用?PHP EngineInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EngineInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function it_should_return_converted_data(Request $request, Convert $convert, EngineInterface $templating)
{
$result = $this->indexAction($request);
$convert->convert(Argument::any([]), Argument::any('string'))->shouldBeCalled();
$convert->convert(Argument::any([]), Argument::any('string'))->willReturn('string');
$templating->render('default/index.html.twig', array('result' => $result));
}
示例2: DashboardStatistics
function it_renders_dashboard_with_statistics(Request $request, DashboardStatisticsProviderInterface $dashboardStatsProvider, EngineInterface $templatingEngine, Response $response)
{
$dashboardStats = new DashboardStatistics(1245, 5, 6);
$dashboardStatsProvider->getStatistics()->willReturn($dashboardStats);
$templatingEngine->renderResponse('SyliusAdminBundle:Dashboard:index.html.twig', ['statistics' => $dashboardStats])->willReturn($response);
$this->indexAction($request)->shouldReturn($response);
}
示例3: array
/**
* @param \Symfony\Bundle\FrameworkBundle\Templating\EngineInterface $templating
* @param \Symfony\Component\Form\FormInterface $form
* @param \Symfony\Component\Form\FormView $formView
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Symfony\Component\HttpFoundation\Response $response
*/
function it_render_template_with_change_password_form($templating, $form, $formView, $request, $response)
{
$form->handleRequest($request)->shouldBeCalled();
$form->isValid()->shouldBeCalled()->willReturn(false);
$form->createView()->shouldBeCalled()->willReturn($formView);
$templating->renderResponse('FSiAdminSecurityBundle:Admin:change_password.html.twig', array('form' => $formView))->shouldBeCalled()->willReturn($response);
$this->changePasswordAction($request)->shouldReturn($response);
}
示例4: 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());
}
示例5: indexAction
public function indexAction(Request $request, $configurationId)
{
$configuration = $this->getConfigurationOr404($configurationId);
$pagination = $this->createPagination($configuration, $request);
$reports = $this->reportManager->getJobReportsByConfiguration($configuration, $pagination->getOffset(), $pagination->getPerPage());
return $this->templating->renderResponse('AurejaJobQueueBundle:JobReport:index.html.twig', ['configuration' => $this->getConfigurationOr404($configurationId), 'pagination' => $pagination, 'reports' => $reports]);
}
示例6: associationsAction
/**
* Display association grids
*
* @param Request $request the request
* @param integer $id the product id (owner)
*
* @AclAncestor("pim_enrich_associations_view")
*
* @return Response
*/
public function associationsAction(Request $request, $id)
{
$product = $this->findProductOr404($id);
$this->productManager->ensureAllAssociationTypes($product);
$associationTypes = $this->doctrine->getRepository('PimCatalogBundle:AssociationType')->findAll();
return $this->templating->renderResponse('PimEnrichBundle:Association:_associations.html.twig', array('product' => $product, 'associationTypes' => $associationTypes, 'dataLocale' => $request->get('dataLocale', null)));
}
示例7: findTemplate
/**
* Returns template.
*
* @return string
*/
private function findTemplate()
{
if ($this->templateName !== null && $this->templateEngine->exists($this->templateName)) {
return $this->templateName;
}
return 'TwigBundle:Exception:exception_full.html.twig';
}
示例8: 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);
}
示例9: onCoreRequest
/**
* @param GetResponseEvent $event
*/
public function onCoreRequest(GetResponseEvent $event)
{
if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
return;
}
$token = $this->securityContext->getToken();
if (!$token) {
return;
}
if (!$token instanceof UsernamePasswordToken) {
return;
}
$key = $this->helper->getSessionKey($this->securityContext->getToken());
$request = $event->getRequest();
$session = $event->getRequest()->getSession();
$user = $this->securityContext->getToken()->getUser();
if (!$session->has($key)) {
return;
}
if ($session->get($key) === true) {
return;
}
$state = 'init';
if ($request->getMethod() == 'POST') {
if ($this->helper->checkCode($user, $request->get('_code')) == true) {
$session->set($key, true);
return;
}
$state = 'error';
}
$event->setResponse($this->templating->renderResponse('SonataUserBundle:Admin:Security/two_step_form.html.twig', array('state' => $state)));
}
示例10: onResponse
/**
* Checking request and response and decide whether we need a redirect
*
* @param FilterResponseEvent $event
*/
public function onResponse(FilterResponseEvent $event)
{
$request = $event->getRequest();
$response = $event->getResponse();
if ($request->get(self::HASH_NAVIGATION_HEADER) || $request->headers->get(self::HASH_NAVIGATION_HEADER)) {
$location = '';
$isFullRedirect = false;
if ($response->isRedirect()) {
$location = $response->headers->get('location');
if ($request->attributes->get('_fullRedirect') || !is_object($this->security->getToken())) {
$isFullRedirect = true;
}
}
if ($response->isNotFound() || $response->getStatusCode() == 503 && !$this->isDebug) {
$location = $request->getUri();
$isFullRedirect = true;
}
if ($location) {
$response = $this->templating->renderResponse('OroNavigationBundle:HashNav:redirect.html.twig', array('full_redirect' => $isFullRedirect, 'location' => $location));
}
// disable cache for ajax navigation pages and change content type to json
$response->headers->set('Content-Type', 'application/json');
$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);
$event->setResponse($response);
}
}
示例11: 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);
}
}
示例12: 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));
}
示例13: loginAction
public function loginAction(Request $request)
{
$form = $this->formFactory->create(LoginType::class);
if ($error = $this->getAuthenticationError($request)) {
$form->addError(new FormError($error->getMessage()));
}
return $this->templating->renderResponse('Security/login.html.twig', ['form' => $form->createView()]);
}
示例14: onJobCreated
/**
* @param JobEvent $jobEvent
*/
public function onJobCreated(JobEvent $jobEvent)
{
$job = $jobEvent->getJob();
// Notification message to User
$this->jobBoardMailer->sendMessage(sprintf('The job %s has been Sent', $job->getTitle()), 'no-reply@hossamyoussef.com', $job->getEmail(), $this->templating->renderResponse('Email/user.html.twig', array('job' => $job)));
// Notification message to Job-Board Moderator
$this->jobBoardMailer->sendMessage(sprintf('The job %s has been created', $job->getTitle()), 'no-reply@hossamyoussef.com', 'admin@hossamyoussef.com', $this->templating->renderResponse('Email/moderator.html.twig', array('job' => $job)));
}
示例15: 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;
}