Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
 {
     $code = $exception->getStatusCode();
     $showException = $request->attributes->get('showException', $this->debug);
     $template = $this->requestAnalyzer->getWebspace()->getTheme()->getErrorTemplate($code);
     if ($showException || $request->getRequestFormat() !== 'html' || $template === null) {
         return parent::showAction($request, $exception, $logger);
     }
     $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
     $parameter = ['status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'currentContent' => $currentContent];
     $data = $this->parameterResolver->resolve($parameter, $this->requestAnalyzer);
     return new Response($this->twig->render($template, $data), $code);
 }
Beispiel #2
0
 /**
  * Returns the search results for the given query.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function queryAction(Request $request)
 {
     $query = $this->getRequestParameter($request, 'q', true);
     $locale = $this->requestAnalyzer->getCurrentLocalization()->getLocale();
     $webspace = $this->requestAnalyzer->getWebspace();
     $queryString = '';
     if (strlen($query) < 3) {
         $queryString .= '+("' . self::escapeDoubleQuotes($query) . '") ';
     } else {
         $queryValues = explode(' ', $query);
         foreach ($queryValues as $queryValue) {
             if (strlen($queryValue) > 2) {
                 $queryString .= '+("' . self::escapeDoubleQuotes($queryValue) . '" OR ' . preg_replace('/([^\\pL\\s\\d])/u', '?', $queryValue) . '* OR ' . preg_replace('/([^\\pL\\s\\d])/u', '', $queryValue) . '~) ';
             } else {
                 $queryString .= '+("' . self::escapeDoubleQuotes($queryValue) . '") ';
             }
         }
     }
     $hits = $this->searchManager->createSearch($queryString)->locale($locale)->index('page_' . $webspace->getKey() . '_published')->execute();
     return $this->engine->renderResponse($webspace->getTemplate('search'), $this->parameterResolver->resolve(['query' => $query, 'hits' => $hits], $this->requestAnalyzer));
 }
 /**
  *
  * @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;
 }