You are here

public function RouteContentEnhancer::enhance in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony-cmf/routing/Enhancer/RouteContentEnhancer.php \Symfony\Cmf\Component\Routing\Enhancer\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

vendor/symfony-cmf/routing/Enhancer/RouteContentEnhancer.php, line 54

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;
  }

  /** @var $route RouteObjectInterface */
  $route = $defaults[$this->routefield];
  $content = $route
    ->getContent();
  if (!$content) {

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