You are here

public function RouteSubscriber::alterRoutes in Block Region Permissions 8

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 16

Class

RouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\block_region_permissions\Routing

Code

public function alterRoutes(RouteCollection $collection) {

  // Change access callback for the block edit and delete forms.
  $routeNames = [
    'entity.block.edit_form',
    'entity.block.delete_form',
  ];
  foreach ($routeNames as $name) {
    if ($route = $collection
      ->get($name)) {
      $route
        ->addRequirements([
        '_custom_access' => 'Drupal\\block_region_permissions\\AccessControlHandler::blockFormAccess',
      ]);
    }
  }
}