You are here

public function RouteSubscriber::alterRoutes in Edit own user account permission 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\edit_own_user_account_permission\Routing

Code

public function alterRoutes(RouteCollection $collection) {

  // Always check with custom access to '/user/{uid}/edit'.
  if ($route = $collection
    ->get('entity.user.edit_form')) {
    $route
      ->setRequirement('_custom_access', '\\Drupal\\edit_own_user_account_permission\\Access\\EditOwnUserAccountAccessCheck::access');
  }
}