public function RouteContentEnhancer::enhance

If the route has a non-null content and if that content class is in the injected map, returns that controller.

Overrides RouteEnhancerInterface::enhance

File

drupal/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Enhancer/RouteContentEnhancer.php, line 46

Class

RouteContentEnhancer
This enhancer sets the content to target field if the route provides content

Namespace

Symfony\Cmf\Component\Routing\Enhancer

Code

public function enhance(array $defaults, Request $request) {
  if (isset($defaults[$this->target])) {

    // no need to do anything
    return $defaults;
  }
  if (!isset($defaults[$this->routefield]) || !$defaults[$this->routefield] instanceof RouteObjectInterface) {

    // we can't determine the content
    return $defaults;
  }
  $route = $defaults[$this->routefield];
  $content = $route
    ->getRouteContent();
  if (!$content) {

    // we have no content
    return $defaults;
  }
  $defaults[$this->target] = $content;
  return $defaults;
}