You are here

class RouteSubscriber in Opigno statistics 8

Same name and namespace in other branches
  1. 3.x src/EventSubscriber/RouteSubscriber.php \Drupal\opigno_statistics\EventSubscriber\RouteSubscriber

Class RouteSubscriber.

Hierarchy

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

Expanded class hierarchy of RouteSubscriber

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

File

src/EventSubscriber/RouteSubscriber.php, line 11

Namespace

Drupal\opigno_statistics\EventSubscriber
View source
class RouteSubscriber extends RouteSubscriberBase {

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

    // Replace default user profile route.
    $user_page = $collection
      ->get('opigno_statistics.user');
    if (isset($user_page)) {
      $default_user_page_key = 'entity.user.canonical';
      $default_user_page = $collection
        ->get($default_user_page_key);
      $user_page
        ->setPath($default_user_page
        ->getPath());
      $collection
        ->remove($default_user_page_key);
      $collection
        ->add($default_user_page_key, $user_page);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
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