You are here

public function RouteSubscriber::alterRoutes in Contact Storage 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 17

Class

RouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\contact_storage\Routing

Code

public function alterRoutes(RouteCollection $collection) {

  // Change the contact_form controller.
  if ($route = $collection
    ->get('entity.contact_form.canonical')) {
    $route
      ->setDefault('_controller', ContactStorageController::class . '::contactSitePage');
    $route
      ->setDefault('_title_callback', ContactStorageController::class . '::contactFormTitle');
  }
  if ($route = $collection
    ->get('entity.contact_form.edit_form')) {
    $route
      ->setDefault('_title_callback', ContactStorageController::class . '::contactEditFormTitle');
  }
}