You are here

public function FormModesSubscriber::setFormModeCollection 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::setFormModeCollection()

Create a route for given form mode and operation form handler.

This method add a route for given form mode and respect the standard, of parent entity routing naming. All routes added in collection are, based on parrent route parameters and only add only, the minimum to use form modes. The route add only if parent entity, declare to use this operation in `entityRoutingMap` plugin.

Parameters

array $form_mode_infos: A form-mode for specified entity_type_id.

string $operation_name: The entity operation name.

1 call to FormModesSubscriber::setFormModeCollection()
FormModesSubscriber::addFormModesRoutes in src/Routing/EventSubscriber/FormModesSubscriber.php
Add a collection of route per form mode for current entity.

File

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

Class

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

Namespace

Drupal\form_mode_manager\Routing\EventSubscriber

Code

public function setFormModeCollection(array $form_mode_infos, $operation_name) {
  if ($this->entityRoutingDefinition
    ->getOperation($operation_name) && ($route = $this
    ->getFormModeRoute($form_mode_infos, $operation_name))) {
    $form_mode_name = $this->formModeManager
      ->getFormModeMachineName($form_mode_infos['id']);
    $form_mode_route_name = "{$this->entityRoutingDefinition->getOperation($operation_name)}.{$form_mode_name}";
    $this->routeCollection
      ->add($form_mode_route_name, $route);
  }
}