public function FormModesSubscriber::setFormModeCollection in Form mode manager 8
Same name and namespace in other branches
- 8.2 src/Routing/EventSubscriber/FormModesSubscriber.php \Drupal\form_mode_manager\Routing\EventSubscriber\FormModesSubscriber::setFormModeCollection()
Create a route per form_mode for given operation form.
Parameters
\Symfony\Component\Routing\RouteCollection $collection: The route collection to retrieve parent entity routes.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.
array $form_mode: A form-mode for specified entity_type_id.
string $operation: The entity operation name.
1 call to FormModesSubscriber::setFormModeCollection()
- FormModesSubscriber::addFormModesRoutes in src/
Routing/ EventSubscriber/ FormModesSubscriber.php - Generate all operations routes for entities.
File
- src/
Routing/ EventSubscriber/ FormModesSubscriber.php, line 127
Class
- FormModesSubscriber
- Subscriber for form_mode_manager routes.
Namespace
Drupal\form_mode_manager\Routing\EventSubscriberCode
public function setFormModeCollection(RouteCollection $collection, EntityTypeInterface $entity_type, array $form_mode, $operation) {
/** @var \Drupal\form_mode_manager\EntityRoutingMapBase $entity_operation_mapping */
$entity_operation_mapping = $this->entityRoutingMap
->createInstance($entity_type
->id(), [
'entityTypeId' => $entity_type
->id(),
]);
if ($entity_operation_mapping
->getOperation($operation) && ($route = $this
->getFormModeRoute($collection, $entity_type, $form_mode, $operation))) {
$form_mode_name = $this->formModeManager
->getFormModeMachineName($form_mode['id']);
$collection
->add($entity_operation_mapping
->getOperation($operation) . ".{$form_mode_name}", $route);
}
}