You are here

RouteSubscriber.php in Create user permission 8

Same filename and directory in other branches
  1. 2.x src/Routing/RouteSubscriber.php

File

src/Routing/RouteSubscriber.php
View source
<?php

namespace Drupal\create_user_permission\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Class RouteSubscriber.
 *
 * @package Drupal\create_user_permission\Routing
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection
      ->get('user.admin_create')) {
      $route
        ->setRequirement('_permission', 'create users');
    }
  }

}

Classes

Namesort descending Description
RouteSubscriber Class RouteSubscriber.