You are here

RouteSubscriber.php in Opigno Learning path 8

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

File

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

namespace Drupal\opigno_learning_path\Routing;

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

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {

    // Alters '/group/{group}/members' route path from Group module
    // to use this path in custom controller.
    if ($route = $collection
      ->get('view.group_members.page_1')) {
      $route
        ->setPath('/group/{group}/members/default');
    }
    if ($route = $collection
      ->get('entity.group.join')) {
      $route
        ->setRequirement('_entity_access', 'group.join');
    }
  }

}

Classes

Namesort descending Description
RouteSubscriber Listens to the dynamic route events.