But you can specify different classes to handle particular Route Parts.
Note: Route Part handlers must implement
\Neos\Flow\Mvc\Routing\DynamicRoutePartInterface.
Usage: setRoutePartsConfiguration(array('@controller' =>
array('handler' => \Neos\Package\Subpackage\MyRoutePartHandler::class)));
public setRoutePartsConfiguration ( array $routePartsConfiguration ) : void | ||
$routePartsConfiguration | array | Route Parts configuration options |
return | void |
/** * @test */ public function parseSetsDefaultValueOfRoutePartsRecursively() { $this->route->setUriPattern('{foo.bar}'); $this->route->setRoutePartsConfiguration(['foo.bar' => ['handler' => 'SomeRoutePartHandler']]); $this->route->setDefaults(['foo' => ['bar' => 'SomeDefaultValue']]); $mockRoutePartHandler = $this->createMock(Routing\DynamicRoutePartInterface::class); $mockRoutePartHandler->expects($this->once())->method('setDefaultValue')->with('SomeDefaultValue'); $this->mockObjectManager->expects($this->once())->method('get')->with('SomeRoutePartHandler')->will($this->returnValue($mockRoutePartHandler)); $this->route->parse(); }
/** * Creates \Neos\Flow\Mvc\Routing\Route objects from the injected routes * configuration. * * @return void * @throws InvalidRouteSetupException */ protected function createRoutesFromConfiguration() { if ($this->routesCreated === true) { return; } $this->initializeRoutesConfiguration(); $this->routes = []; $routesWithHttpMethodConstraints = []; foreach ($this->routesConfiguration as $routeConfiguration) { $route = new Route(); if (isset($routeConfiguration['name'])) { $route->setName($routeConfiguration['name']); } $uriPattern = $routeConfiguration['uriPattern']; $route->setUriPattern($uriPattern); if (isset($routeConfiguration['defaults'])) { $route->setDefaults($routeConfiguration['defaults']); } if (isset($routeConfiguration['routeParts'])) { $route->setRoutePartsConfiguration($routeConfiguration['routeParts']); } if (isset($routeConfiguration['toLowerCase'])) { $route->setLowerCase($routeConfiguration['toLowerCase']); } if (isset($routeConfiguration['appendExceedingArguments'])) { $route->setAppendExceedingArguments($routeConfiguration['appendExceedingArguments']); } if (isset($routeConfiguration['httpMethods'])) { if (isset($routesWithHttpMethodConstraints[$uriPattern]) && $routesWithHttpMethodConstraints[$uriPattern] === false) { throw new InvalidRouteSetupException(sprintf('There are multiple routes with the uriPattern "%s" and "httpMethods" option set. Please specify accepted HTTP methods for all of these, or adjust the uriPattern', $uriPattern), 1365678427); } $routesWithHttpMethodConstraints[$uriPattern] = true; $route->setHttpMethods($routeConfiguration['httpMethods']); } else { if (isset($routesWithHttpMethodConstraints[$uriPattern]) && $routesWithHttpMethodConstraints[$uriPattern] === true) { throw new InvalidRouteSetupException(sprintf('There are multiple routes with the uriPattern "%s" and "httpMethods" option set. Please specify accepted HTTP methods for all of these, or adjust the uriPattern', $uriPattern), 1365678432); } $routesWithHttpMethodConstraints[$uriPattern] = false; } $this->routes[] = $route; } $this->routesCreated = true; }