You are here

protected function FormModesSubscriber::getFormModeRouteOptions 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::getFormModeRouteOptions()

Get options parameters nedeed to build Form Mode Manager routes.

Parameters

array $form_mode_infos: The form mode info.

Return value

array Array contain options routes parameters.

1 call to FormModesSubscriber::getFormModeRouteOptions()
FormModesSubscriber::setRoutes in src/Routing/EventSubscriber/FormModesSubscriber.php
Generate a routes based on top of given parent routes.

File

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

Class

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

Namespace

Drupal\form_mode_manager\Routing\EventSubscriber

Code

protected function getFormModeRouteOptions(array $form_mode_infos) {
  $entity_definition = $this->entityDefinition;
  $entity_type_id = $entity_definition
    ->id();
  $route_definition = [
    '_form_mode_manager_entity_type_id' => $entity_type_id,
    'form_mode_theme' => NULL,
    'parameters' => [
      $entity_type_id => [
        'type' => "entity:{$entity_type_id}",
      ],
      'form_mode' => $form_mode_infos + [
        'type' => NULL,
      ],
    ],
  ];
  if (!empty($entity_definition
    ->getKey('bundle'))) {
    $route_definition['_form_mode_manager_bundle_entity_type_id'] = $entity_definition
      ->getBundleEntityType();
  }
  return $route_definition;
}