예제 #1
0
 /**
  * Searches for a matching redirect for the given HTTP response
  *
  * @param Request $httpRequest
  * @return Response|null
  * @api
  */
 public function buildResponseIfApplicable(Request $httpRequest)
 {
     try {
         $redirect = $this->redirectStorage->getOneBySourceUriPathAndHost($httpRequest->getRelativePath(), $httpRequest->getBaseUri()->getHost());
         if ($redirect === null) {
             return null;
         }
         if (isset($this->featureSwitch['hitCounter']) && $this->featureSwitch['hitCounter'] === true) {
             $this->redirectStorage->incrementHitCount($redirect);
         }
         return $this->buildResponse($httpRequest, $redirect);
     } catch (\Exception $exception) {
         // Throw exception if it's a \Neos\RedirectHandler\Exception (used for custom exception handling)
         if ($exception instanceof Exception) {
             throw $exception;
         }
         // skip triggering the redirect if there was an error accessing the database (wrong credentials, ...)
         return null;
     }
 }