You are here

protected function RouteSubscriber::alterRoutes in Allow a content type only once (Only One) 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 45

Class

RouteSubscriber
Class RouteSubscriber.

Namespace

Drupal\onlyone\Routing

Code

protected function alterRoutes(RouteCollection $collection) {

  // Cleaning the action link cache.
  $this->localActionManager
    ->clearCachedDefinitions();

  // Removing the onlyone.add_page route if is not needed and exists.
  if (!$this->configFactory
    ->get('onlyone.settings')
    ->get('onlyone_new_menu_entry') && $collection
    ->get('onlyone.add_page')) {
    $collection
      ->remove('onlyone.add_page');
  }
}