/** * {@inheritdoc} */ public function process(Request $request, RequestAttributes $requestAttributes) { $portalInformation = $requestAttributes->getAttribute('portalInformation'); if (!$portalInformation instanceof PortalInformation) { return new RequestAttributes(); } $attributes = ['requestUri' => $request->getUri()]; if (null !== ($localization = $portalInformation->getLocalization())) { $request->setLocale($localization->getLocalization()); } $attributes['portalInformation'] = $portalInformation; $attributes['getParameter'] = $request->query->all(); $attributes['postParameter'] = $request->request->all(); $attributes['matchType'] = $portalInformation->getType(); $attributes['redirect'] = $portalInformation->getRedirect(); $attributes['analyticsKey'] = $portalInformation->getAnalyticsKey(); $attributes['portalUrl'] = $portalInformation->getUrl(); $attributes['webspace'] = $portalInformation->getWebspace(); $attributes['portal'] = $portalInformation->getPortal(); if ($portalInformation->getType() === RequestAnalyzerInterface::MATCH_TYPE_REDIRECT) { return new RequestAttributes($attributes); } $attributes['localization'] = $portalInformation->getLocalization(); $attributes['segment'] = $portalInformation->getSegment(); list($resourceLocator, $format) = $this->getResourceLocatorFromRequest($portalInformation, $request); $attributes['urlExpression'] = $portalInformation->getUrlExpression(); $attributes['resourceLocator'] = $resourceLocator; $attributes['format'] = $format; $attributes['resourceLocatorPrefix'] = substr($portalInformation->getUrl(), strlen($request->getHttpHost())); if (null !== $format) { $request->setRequestFormat($format); } return new RequestAttributes($attributes); }
/** * {@inheritdoc} */ public function validate(RequestAttributes $attributes) { if (null === $attributes->getAttribute('portalInformation')) { throw new UrlMatchNotFoundException($attributes->getAttribute('requestUri')); } return true; }
/** * Returns request attribute with given name. * * @param string $name * @param mixed|null $default * * @return mixed */ public function getAttribute($name, $default = null) { return $this->requestAttributes->getAttribute($name, $default); }