public function ContentControllerEnhancer::enhance

Update the defaults based on its own data and the request.

Parameters

array $defaults the getRouteDefaults array:

Return value

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

Overrides RouteEnhancerInterface::enhance

File

drupal/core/lib/Drupal/Core/Routing/Enhancer/ContentControllerEnhancer.php, line 50
Contains \Drupal\Core\Routing\Enhancer\ContentControllerEnhancer.

Class

ContentControllerEnhancer
Enhances a route to select a controller based on the mime type of the request.

Namespace

Drupal\Core\Routing\Enhancer

Code

public function enhance(array $defaults, Request $request) {
  if (empty($defaults['_controller']) && !empty($defaults['_content'])) {
    $type = $this->negotiation
      ->getContentType($request);
    if (isset($this->types[$type])) {
      $defaults['_controller'] = $this->types[$type];
    }
  }
  return $defaults;
}