You are here

public function RouteSubscriber::alterRoutes in Answers 8

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 16

Class

RouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\answers\Routing

Code

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',
    ]);
  }
}