You are here

public function RouteEnhancer::enhance in Automatic Entity Label 8.2

Same name and namespace in other branches
  1. 8.3 src/Routing/RouteEnhancer.php \Drupal\auto_entitylabel\Routing\RouteEnhancer::enhance()
  2. 8 src/Routing/RouteEnhancer.php \Drupal\auto_entitylabel\Routing\RouteEnhancer::enhance()

File

src/Routing/RouteEnhancer.php, line 39

Class

RouteEnhancer
RouteEnhancer Class.

Namespace

Drupal\auto_entitylabel\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])) {

    // Auto Entity Label 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;
}