routefield = $routefield; $this->target = $target; } /** * If the route has a non-null content and if that content class is in the * injected map, returns that controller. * * {@inheritdoc} */ public function enhance(array $defaults, Request $request) { if (array_key_exists($this->target, $defaults)) { // no need to do anything return $defaults; } if (!array_key_exists($this->routefield, $defaults) || !$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; } }