本文整理汇总了PHP中Symfony\Component\Templating\EngineInterface::renderResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP EngineInterface::renderResponse方法的具体用法?PHP EngineInterface::renderResponse怎么用?PHP EngineInterface::renderResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Templating\EngineInterface
的用法示例。
在下文中一共展示了EngineInterface::renderResponse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
}
示例2: renderResponse
protected function renderResponse($contentTemplate, $params)
{
if ($this->viewHandler) {
$view = new View($params);
$view->setTemplate($contentTemplate);
return $this->viewHandler->handle($view);
}
return $this->templating->renderResponse($contentTemplate, $params);
}
示例3: 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');
$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));
}
}
示例4: detailAction
/**
*
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function detailAction(Request $request)
{
$event = $this->eventManager->findByIdAndLocale($request->get('id'), 'de', true);
if (!$event) {
throw new NotFoundHttpException(404);
}
$filter['lat'] = $event->getLatitude();
$filter['long'] = $event->getLongitude();
$filter['area'] = 100;
$requestData = $this->requestAnalyzerResolver->resolve($this->requestAnalyzer);
$resolverData = $this->parameterResolver->resolve(array(), $this->requestAnalyzer, null, false);
$response = $this->templating->renderResponse('SuluEventBundle:templates:detail.html.twig', array_merge(array('event' => $event, 'urls' => isset($resolverData['urls']) ? $resolverData['urls'] : array()), $requestData));
$response->setMaxAge($this->cacheMaxAge);
$response->setSharedMaxAge($this->cacheSharedMaxAge);
return $response;
}
示例5: performAction
/**
* Launch the background process related to the mass edit action
*
* @AclAncestor("pim_enrich_mass_edit")
*
* @param Request $request
* @param string $operationAlias
*
* @throws NotFoundResourceException
*
* @return Response
*/
public function performAction(Request $request, $operationAlias)
{
$form = $this->massEditFormResolver->getConfigurationForm($operationAlias);
$itemsCount = $request->get('itemsCount');
$configureTemplate = $this->getPerformOperationTemplate($operationAlias);
$form->remove('operationAlias');
$form->submit($request);
$queryParams = $this->getQueryParams($request);
if ($form->isValid()) {
$pimFilters = $this->gridFilterAdapter->adapt($request);
$operation = $form->getData();
$operation->setFilters($pimFilters);
$this->operationLauncher->launch($operation);
$request->getSession()->getFlashBag()->add('success', new Message(sprintf('pim_enrich.mass_edit_action.%s.launched_flash', $operationAlias)));
$redirectRoute = $this->getPerformOperationRedirectRoute();
return new RedirectResponse($this->router->generate($redirectRoute, ['dataLocale' => $queryParams['dataLocale']]));
}
return $this->templating->renderResponse($configureTemplate, ['form' => $form->createView(), 'operationAlias' => $operationAlias, 'itemsCount' => $itemsCount, 'queryParams' => $queryParams]);
}
示例6: render
/**
* Renders a view.
*
* @param string $view The view name
* @param array $parameters An array of parameters to pass to the view
* @param Response $response A response instance
*
* @return Response A Response instance
*/
public function render($view, array $parameters = [], Response $response = null)
{
return $this->templating->renderResponse($view, $parameters, $response);
}
示例7: historyAction
/**
* History of a group
*
* TODO : find a way to use param converter with interfaces
*
* @param Group $group
*
* @AclAncestor("pim_enrich_group_history")
*
* @return Response
*/
public function historyAction(Group $group)
{
return $this->templating->renderResponse('PimEnrichBundle:Group:Tab/_history.html.twig', ['group' => $group]);
}
示例8: listAction
public function listAction($page)
{
return $this->templating->renderResponse('scene/standalone/list.html.twig', ['scenes' => $this->getScenes($page)]);
}