You are here

public function FlexiformRouteEnhancer::enhance in Flexiform 8

File

src/Routing/FlexiformRouteEnhancer.php, line 37

Class

FlexiformRouteEnhancer
Enhances Flexiform routes.

Namespace

Drupal\flexiform\Routing

Code

public function enhance(array $defaults, Request $request) {

  /* @var \Symfony\Component\Routing\Route $route */
  $route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
  if (!$route
    ->hasOption('_flexiform_form_entity')) {
    return $defaults;
  }
  $defaults['form_display'] = $this->entityTypeManager
    ->getStorage('entity_form_display')
    ->load($defaults['entity_type_id'] . '.' . $defaults['bundle'] . '.' . $defaults['form_mode_name']);
  return $defaults;
}