You are here

public function ParamConversionEnhancer::enhance in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer::enhance()
  2. 9 core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer::enhance()

Updates the defaults for a route definition based on the request.

Parameters

array $defaults: The defaults, maps to '_defaults' in the route definition YAML.

\Symfony\Component\HttpFoundation\Request $request: The Request instance.

Return value

array The modified defaults. Each enhancer MUST return the $defaults but may add or remove values.

Overrides EnhancerInterface::enhance

File

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

Class

ParamConversionEnhancer
Provides a route enhancer that handles parameter conversion.

Namespace

Drupal\Core\Routing\Enhancer

Code

public function enhance(array $defaults, Request $request) {

  // Just run the parameter conversion once per request.
  if (!isset($defaults['_raw_variables'])) {
    $defaults['_raw_variables'] = $this
      ->copyRawVariables($defaults);
    $defaults = $this->paramConverterManager
      ->convert($defaults);
  }
  return $defaults;
}