You are here

public static function RouteAttributes::extractRawAttributes in Page Manager 8

Same name and namespace in other branches
  1. 8.4 src/Routing/RouteAttributes.php \Drupal\page_manager\Routing\RouteAttributes::extractRawAttributes()

Extracts all of the raw attributes from a path for a given route.

Parameters

\Symfony\Component\Routing\Route $route: The route object.

string $name: The route name.

string $path: A path.

Return value

array An array of raw attributes for this path and route.

2 calls to RouteAttributes::extractRawAttributes()
RouteAttributesTest::testExtractRawAttributes in tests/src/Unit/RouteAttributesTest.php
@covers ::extractRawAttributes
VariantRouteFilter::getRequestAttributes in src/Routing/VariantRouteFilter.php
Prepares the request attributes for use by the selection process.

File

src/Routing/RouteAttributes.php, line 33
Contains \Drupal\page_manager\Routing\RouteAttributes.

Class

RouteAttributes
Provides utilities for interacting with route attributes.

Namespace

Drupal\page_manager\Routing

Code

public static function extractRawAttributes(Route $route, $name, $path) {

  // See \Symfony\Component\Routing\Matcher\UrlMatcher::matchCollection().
  preg_match($route
    ->compile()
    ->getRegex(), $path, $matches);

  // See \Symfony\Component\Routing\Matcher\UrlMatcher::mergeDefaults().
  $attributes = $route
    ->getDefaults();
  foreach ($matches as $key => $value) {
    if (!is_int($key)) {
      $attributes[$key] = $value;
    }
  }

  // See \Symfony\Cmf\Component\Routing\NestedMatcher\UrlMatcher::getAttributes().
  $attributes[RouteObjectInterface::ROUTE_OBJECT] = $route;
  $attributes[RouteObjectInterface::ROUTE_NAME] = $name;
  return $attributes;
}