public getRouteReference ( ) : |
||
Résultat |
public function testGetSet() { $routeReference = new RouteReference('foo'); $request = new Request(); $event = new RouteReferenceGenerationEvent($routeReference, $request); $this->assertSame($routeReference, $event->getRouteReference()); $this->assertSame($request, $event->getRequest()); $newRouteReference = new RouteReference('bar'); $event->setRouteReference($newRouteReference); $this->assertSame($newRouteReference, $event->getRouteReference()); }
/** * If "language" parameter is present, will try to get corresponding SiteAccess for translation. * If found, it will add "siteaccess" parameter to the RouteReference, to trigger SiteAccess switch when generating * the final link. * * @see \eZ\Publish\Core\MVC\Symfony\Routing\Generator::generate() * @see \eZ\Publish\Core\MVC\Symfony\Routing\Generator\UrlAliasGenerator::doGenerate() * * @param \eZ\Publish\Core\MVC\Symfony\Event\RouteReferenceGenerationEvent $event */ public function onRouteReferenceGeneration(RouteReferenceGenerationEvent $event) { $routeReference = $event->getRouteReference(); if (!$routeReference->has('language')) { return; } $language = $routeReference->get('language'); $routeReference->remove('language'); $siteAccess = $this->translationHelper->getTranslationSiteAccess($language); if ($siteAccess !== null) { $routeReference->set('siteaccess', $siteAccess); } }
/** * @throws \InvalidArgumentException If the required arguments are not correct */ public function onRouteReferenceGeneration(RouteReferenceGenerationEvent $event) { $routeReference = $event->getRouteReference(); if ($routeReference->getRoute() != self::ROUTE_NAME) { return; } $options = $routeReference->getParams(); $resolver = new OptionsResolver(); $this->configureOptions($resolver); $options = $resolver->resolve($options); if (isset($options[self::OPT_DOWNLOAD_LANGUAGE])) { $routeReference->set(self::OPT_DOWNLOAD_LANGUAGE, $options[self::OPT_DOWNLOAD_LANGUAGE]); } if (isset($options[self::OPT_VERSION])) { $routeReference->set(self::OPT_VERSION, $options[self::OPT_VERSION]); } $routeReference->set(self::OPT_CONTENT_ID, $options[self::OPT_CONTENT_ID]); $routeReference->set(self::OPT_DOWNLOAD_NAME, $options[self::OPT_DOWNLOAD_NAME]); }