You are here

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

Generate a routes based on top of given parent routes.

Parameters

\Symfony\Component\Routing\Route $parent_route: The route object of entity.

array $form_mode_infos: The form mode info.

Return value

\Symfony\Component\Routing\Route Form Mode Manager route to be added on entity collection.

1 call to FormModesSubscriber::setRoutes()
FormModesSubscriber::getFormModeRoute in src/Routing/EventSubscriber/FormModesSubscriber.php
Get the Form Mode Manager route for given operation.

File

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

Class

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

Namespace

Drupal\form_mode_manager\Routing\EventSubscriber

Code

protected function setRoutes(Route $parent_route, array $form_mode_infos) {
  $route_path = implode('/', [
    $parent_route
      ->getPath(),
    $this->formModeManager
      ->getFormModeMachineName($form_mode_infos['id']),
  ]);
  $route_defaults = NestedArray::mergeDeep($parent_route
    ->getDefaults(), $this
    ->getFormModeRouteDefaults($parent_route, $form_mode_infos));
  $route_options = NestedArray::mergeDeep($parent_route
    ->getOptions(), $this
    ->getFormModeRouteOptions($form_mode_infos));
  $route_requirements = NestedArray::mergeDeep($parent_route
    ->getRequirements(), $this
    ->getFormModeRouteRequirements($form_mode_infos));
  return new Route($route_path, $route_defaults, $route_requirements, $route_options);
}