function EntityRouteEnhancer::enhance

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer::enhance()
  2. 8.9.x core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer::enhance()
  3. 11.x core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer::enhance()

Overrides EnhancerInterface::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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.