W3cubDocs

/Drupal 8

protected function ParamConversionEnhancer::copyRawVariables

protected ParamConversionEnhancer::copyRawVariables(array $defaults)

Store a backup of the raw values that corresponding to the route pattern.

Parameters

array $defaults: The route defaults array.

Return value

\Symfony\Component\HttpFoundation\ParameterBag

File

core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php, line 58

Class

ParamConversionEnhancer
Provides a route enhancer that handles parameter conversion.

Namespace

Drupal\Core\Routing\Enhancer

Code

protected function copyRawVariables(array $defaults) {
  /** @var $route \Symfony\Component\Routing\Route */
  $route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
  $variables = array_flip($route->compile()->getVariables());
  // Foreach will copy the values from the array it iterates. Even if they
  // are references, use it to break them. This avoids any scenarios where raw
  // variables also get replaced with converted values.
  $raw_variables = array();
  foreach (array_intersect_key($defaults, $variables) as $key => $value) {
    $raw_variables[$key] = $value;
  }
  return new ParameterBag($raw_variables);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Routing!Enhancer!ParamConversionEnhancer.php/function/ParamConversionEnhancer::copyRawVariables/8.1.x