You are here

class RouteSubscriber in Multiple Registration 8

Same name and namespace in other branches
  1. 8.2 src/Routing/RouteSubscriber.php \Drupal\multiple_registration\Routing\RouteSubscriber
  2. 3.x src/Routing/RouteSubscriber.php \Drupal\multiple_registration\Routing\RouteSubscriber

Listens to the dynamic route events.

Hierarchy

  • class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of RouteSubscriber

1 string reference to 'RouteSubscriber'
multiple_registration.services.yml in ./multiple_registration.services.yml
multiple_registration.services.yml
1 service uses RouteSubscriber
multiple_registration.route_subscriber in ./multiple_registration.services.yml
Drupal\multiple_registration\Routing\RouteSubscriber

File

src/Routing/RouteSubscriber.php, line 13

Namespace

Drupal\multiple_registration\Routing
View source
class RouteSubscriber extends RouteSubscriberBase {
  protected $configFactory;

  /**
   * Constructs a Drupal\multiple_registration\Routing\RouteSubscriber object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The factory for configuration objects.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('config.factory'));
  }

  /**
   * Altering route for the user.register.
   */
  protected function alterRoutes(RouteCollection $collection) {

    // Access denied to '/user/register' when corresponded option is enabled.
    if ($route = $collection
      ->get('user.register')) {
      $disableMain = $this->configFactory
        ->get('multiple_registration.common_settings_page_form_config')
        ->get('multiple_registration_disable_main');
      if ($disableMain === 1) {
        $route
          ->setRequirement('_access', 'FALSE');
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::$configFactory protected property
RouteSubscriber::alterRoutes protected function Altering route for the user.register. Overrides RouteSubscriberBase::alterRoutes
RouteSubscriber::create public static function
RouteSubscriber::__construct public function Constructs a Drupal\multiple_registration\Routing\RouteSubscriber object.
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1