You are here

RouteSubscriber.php in Answers 8

File

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

namespace Drupal\answers\Routing;

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

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

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

    // Change controller class for "node/add".
    if ($route = $collection
      ->get('node.add_page')) {
      $route
        ->setDefaults([
        '_title' => 'Add content',
        '_controller' => '\\Drupal\\answers\\Controller\\AnswersNodeController::addPage',
      ]);
    }
  }

}

Classes

Namesort descending Description
RouteSubscriber Listens to the dynamic route events.