You are here

protected function FormModesSubscriber::getFormModeRouteOptions in Form mode manager 8

Same name and namespace in other branches
  1. 8.2 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: The form mode info.

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

Return value

array Array contain options routes parameters.

1 call to FormModesSubscriber::getFormModeRouteOptions()
FormModesSubscriber::setRoutes in src/Routing/EventSubscriber/FormModesSubscriber.php
Set Form Mode Manager routes based on parent entity routes.

File

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

Class

FormModesSubscriber
Subscriber for form_mode_manager routes.

Namespace

Drupal\form_mode_manager\Routing\EventSubscriber

Code

protected function getFormModeRouteOptions(array $form_mode, EntityTypeInterface $entity_type) {
  $entity_type_id = $entity_type
    ->id();
  $entity_type_bundle_id = $entity_type
    ->getBundleEntityType();
  $bundle_entity_type_id = !empty($entity_type_bundle_id) ? $entity_type_bundle_id : $entity_type_id;
  return [
    '_form_mode_manager_entity_type_id' => $entity_type_id,
    '_form_mode_manager_bundle_entity_type_id' => $bundle_entity_type_id,
    'parameters' => [
      $entity_type_id => [
        'type' => "entity:{$entity_type_id}",
      ],
      'form_mode' => $form_mode + [
        'type' => NULL,
      ],
    ],
  ];
}