You are here

public function EnhanceEntityRouteSubscriber::enhanceDefaultEntityRoute in Form mode manager 8.2

Enhance existing route for given operation name.

Parameters

string $operation_name: The entity operation name.

1 call to EnhanceEntityRouteSubscriber::enhanceDefaultEntityRoute()
EnhanceEntityRouteSubscriber::alterRoutes in src/Routing/EventSubscriber/EnhanceEntityRouteSubscriber.php
Add form mode manager requirements to add more access granularity.

File

src/Routing/EventSubscriber/EnhanceEntityRouteSubscriber.php, line 106

Class

EnhanceEntityRouteSubscriber
Listens to the dynamic route event and enhance existing routes.

Namespace

Drupal\form_mode_manager\Routing\EventSubscriber

Code

public function enhanceDefaultEntityRoute($operation_name) {
  $entity_add_page = $this->entityRoutingDefinition
    ->getOperation($operation_name);
  if ($entity_add_page && ($route = $this->routeCollection
    ->get($entity_add_page))) {
    $route
      ->setRequirement('_permission', "use {$this->entityDefinition->id()}.default form mode");
    $route
      ->setOption('form_mode_theme', NULL);
    $this->routeCollection
      ->add($entity_add_page, $route);
  }
}