You are here

class NodeRevisionRouteSubscriber in Multiversion 8

Alters entity.node.revision route.

Hierarchy

Expanded class hierarchy of NodeRevisionRouteSubscriber

1 string reference to 'NodeRevisionRouteSubscriber'
multiversion.services.yml in ./multiversion.services.yml
multiversion.services.yml
1 service uses NodeRevisionRouteSubscriber
multiversion.node_revision_route_subscriber in ./multiversion.services.yml
Drupal\multiversion\EventSubscriber\NodeRevisionRouteSubscriber

File

src/EventSubscriber/NodeRevisionRouteSubscriber.php, line 15

Namespace

Drupal\multiversion\EventSubscriber
View source
class NodeRevisionRouteSubscriber extends RouteSubscriberBase {

  /**
   * Alters existing route.
   *
   * @param \Symfony\Component\Routing\RouteCollection $collection
   *   The route collection for adding routes.
   */
  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);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events = parent::getSubscribedEvents();
    $events[RoutingEvents::ALTER] = array(
      'onAlterRoutes',
      -500,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NodeRevisionRouteSubscriber::alterRoutes protected function Alters existing route. Overrides RouteSubscriberBase::alterRoutes
NodeRevisionRouteSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase::getSubscribedEvents
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1