You are here

public function EntityRouteEnhancer::enhance in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer::enhance()

File

core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php, line 18

Class

EntityRouteEnhancer
Enhances an entity form route with the appropriate controller.

Namespace

Drupal\Core\Entity\Enhancer

Code

public function enhance(array $defaults, Request $request) {
  $route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
  if (!$this
    ->applies($route)) {
    return $defaults;
  }
  if (empty($defaults['_controller'])) {
    if (!empty($defaults['_entity_form'])) {
      $defaults = $this
        ->enhanceEntityForm($defaults, $request);
    }
    elseif (!empty($defaults['_entity_list'])) {
      $defaults = $this
        ->enhanceEntityList($defaults, $request);
    }
    elseif (!empty($defaults['_entity_view'])) {
      $defaults = $this
        ->enhanceEntityView($defaults, $request);
    }
  }
  return $defaults;
}