You are here

protected function FormModesSubscriber::alterRoutes in Form mode manager 8.2

Same name and namespace in other branches
  1. 8 src/Routing/EventSubscriber/FormModesSubscriber.php \Drupal\form_mode_manager\Routing\EventSubscriber\FormModesSubscriber::alterRoutes()

Add one route collection per entity using form modes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/EventSubscriber/FormModesSubscriber.php, line 109

Class

FormModesSubscriber
Listens to the dynamic route event and add routes using form modes.

Namespace

Drupal\form_mode_manager\Routing\EventSubscriber

Code

protected function alterRoutes(RouteCollection $collection) {
  $this->routeCollection = $collection;
  foreach ($this->formModeManager
    ->getAllFormModesDefinitions() as $entity_type_id => $form_modes) {
    $this->entityDefinition = $this->entityTypeManager
      ->getDefinition($entity_type_id);
    $this->entityRoutingDefinition = $this->entityRoutingMap
      ->createInstance($entity_type_id, [
      'entityTypeId' => $entity_type_id,
    ]);
    $this
      ->addFormModesRoutes($form_modes);
  }
}