You are here

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

Get the Form Mode Manager route for given operation.

Parameters

array $form_mode_infos: The form mode info.

string $operation_name: The entity operation name.

Return value

\Symfony\Component\Routing\Route|null The generated route, if available.

1 call to FormModesSubscriber::getFormModeRoute()
FormModesSubscriber::setFormModeCollection in src/Routing/EventSubscriber/FormModesSubscriber.php
Create a route for given form mode and operation form handler.

File

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

Class

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

Namespace

Drupal\form_mode_manager\Routing\EventSubscriber

Code

public function getFormModeRoute(array $form_mode_infos, $operation_name) {
  $route_name = $this->entityRoutingDefinition
    ->getOperation($operation_name);
  $form_mode_machine_name = $this->formModeManager
    ->getFormModeMachineName($form_mode_infos['id']);
  $entity_type_id = $this->entityDefinition
    ->id();
  if ($this->formModeManager
    ->hasActiveFormMode($entity_type_id, $form_mode_machine_name) && ($entity_edit_route = $this->routeCollection
    ->get($route_name))) {
    return $this
      ->setRoutes($entity_edit_route, $form_mode_infos);
  }
  return NULL;
}