You are here

public function FieldUiRouteEnhancer::enhance in Scheduled Updates 8

File

src/Routing/FieldUiRouteEnhancer.php, line 41
Contains \Drupal\scheduled_updates\Routing\FieldUiRouteEnhancer.

Class

FieldUiRouteEnhancer
Enhances Field UI routes by adding proper information about the bundle name.

Namespace

Drupal\scheduled_updates\Routing

Code

public function enhance(array $defaults, Request $request) {
  if (!$this
    ->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) {
    return $defaults;
  }
  if (($bundle = $this->entityManager
    ->getDefinition($defaults['entity_type_id'])
    ->getBundleEntityType()) && isset($defaults[$bundle])) {

    // Field UI forms only need the actual name of the bundle they're dealing
    // with, not an upcasted entity object, so provide a simple way for them
    // to get it.
    $defaults['bundle'] = $defaults['_raw_variables']
      ->get($bundle);
  }
  return $defaults;
}