You are here

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

Add one route for `add_page` entity operation per form_mode.

This page concern only bundled entities using a route for listing all, bundles using by this entity. Form mode manager add more granularity , permit to choose what bundle is compatible with a specific form mode. This method add one listing route by form mode to provide, these granularity. Not all entities declare a `add_page` operation, because this isn't needed for all usecases but Form mode manager need, to add this possibility as a standard. All routes key are named with to follow these standard, `form_mode_manager.ENTITY_TYPE_ID.add_page.FORM_MODE_NAME`

Parameters

array $form_mode_infos: A form-mode for specified entity_type_id.

1 call to FormModesSubscriber::setAddPageCollection()
FormModesSubscriber::addFormModesRoutes in src/Routing/EventSubscriber/FormModesSubscriber.php
Add a collection of route per form mode for current entity.

File

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

Class

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

Namespace

Drupal\form_mode_manager\Routing\EventSubscriber

Code

public function setAddPageCollection(array $form_mode_infos) {
  $form_mode_name = $this->formModeManager
    ->getFormModeMachineName($form_mode_infos['id']);
  if ($route = $this
    ->getFormModeListPageRoute($form_mode_infos)) {
    $form_mode_route_name = "form_mode_manager.{$this->entityDefinition->id()}.add_page.{$form_mode_name}";
    $this->routeCollection
      ->add($form_mode_route_name, $route);
  }
}