Exemplo n.º 1
0
 /**
  * Prepares the request attributes for use by the selection process.
  *
  * This is be done because route filters run before request attributes are
  * populated.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route.
  * @param string $name
  *   The route name.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request.
  *
  * @return array
  *   An array of request attributes.
  */
 protected function getRequestAttributes(Route $route, $name, Request $request)
 {
     // Extract the raw attributes from the current path. This performs the same
     // functionality as \Drupal\Core\Routing\UrlMatcher::finalMatch().
     $path = $this->currentPath->getPath($request);
     $raw_attributes = RouteAttributes::extractRawAttributes($route, $name, $path);
     $attributes = $request->attributes->all();
     $attributes = NestedArray::mergeDeep($attributes, $raw_attributes);
     // Run the route enhancers on the raw attributes. This performs the same
     // functionality as \Symfony\Cmf\Component\Routing\DynamicRouter::match().
     foreach ($this->getRouteEnhancers() as $enhancer) {
         $attributes = $enhancer->enhance($attributes, $request);
     }
     return $attributes;
 }
Exemplo n.º 2
0
 /**
  * @covers ::extractRawAttributes
  *
  * @dataProvider providerTestExtractRawAttributes
  */
 public function testExtractRawAttributes(Route $route, $name, $path, array $expected)
 {
     $expected['_route_object'] = $route;
     $expected['_route'] = $name;
     $this->assertEquals($expected, RouteAttributes::extractRawAttributes($route, $name, $path));
 }