You are here

public function EntityRouteEnhancer::enhance in Zircon Profile 8.0

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

Update the defaults based on its own data and the request.

Parameters

array $defaults the getRouteDefaults array.:

Request $request the Request instance.:

Return value

array the modified defaults. Each enhancer MUST return the $defaults but may add or remove values.

Overrides RouteEnhancerInterface::enhance

File

core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php, line 23
Contains \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer.

Class

EntityRouteEnhancer
Enhances an entity form route with the appropriate controller.

Namespace

Drupal\Core\Entity\Enhancer

Code

public function enhance(array $defaults, Request $request) {
  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;
}