You are here

protected function NodeRevisionRouteSubscriber::alterRoutes in Multiversion 8

Alters existing route.

Parameters

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

Overrides RouteSubscriberBase::alterRoutes

File

src/EventSubscriber/NodeRevisionRouteSubscriber.php, line 23

Class

NodeRevisionRouteSubscriber
Alters entity.node.revision route.

Namespace

Drupal\multiversion\EventSubscriber

Code

protected function alterRoutes(RouteCollection $collection) {

  // When Diff module is installed we don't need to use
  // MultiversionNodeController::revisionOverview, because we alter the
  // 'revision_overview_form' for in that case.
  // @see multiversion_form_revision_overview_form_alter().
  if (!\Drupal::moduleHandler()
    ->moduleExists('diff')) {
    if ($route = $collection
      ->get('entity.node.version_history')) {
      $route
        ->setDefault('_controller', MultiversionNodeController::class . '::revisionOverview');
    }
  }
  if ($route = $collection
    ->get('node.revision_revert_confirm')) {
    $route
      ->setDefault('_form', MultiversionRevisionRevertForm::class);
  }
  if ($route = $collection
    ->get('node.revision_revert_translation_confirm')) {
    $route
      ->setDefault('_form', MultiversionRevisionRevertTranslationForm::class);
  }
}