You are here

class RouteSubscriber in Config Entity Revisions 8

Same name in this branch
  1. 8 modules/webform_revisions/src/Routing/RouteSubscriber.php \Drupal\webform_revisions\Routing\RouteSubscriber
  2. 8 modules/views_revisions/src/Routing/RouteSubscriber.php \Drupal\views_revisions\Routing\RouteSubscriber
Same name and namespace in other branches
  1. 8.2 modules/webform_revisions/src/Routing/RouteSubscriber.php \Drupal\webform_revisions\Routing\RouteSubscriber
  2. 1.x modules/webform_revisions/src/Routing/RouteSubscriber.php \Drupal\webform_revisions\Routing\RouteSubscriber

Class RouteSubscriber

@package Drupal\webform_revisions\Routing

Hierarchy

  • class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of RouteSubscriber

1 string reference to 'RouteSubscriber'
webform_revisions.services.yml in modules/webform_revisions/webform_revisions.services.yml
modules/webform_revisions/webform_revisions.services.yml
1 service uses RouteSubscriber
webform_revisions.route_subscriber in modules/webform_revisions/webform_revisions.services.yml
Drupal\webform_revisions\Routing\RouteSubscriber

File

modules/webform_revisions/src/Routing/RouteSubscriber.php, line 13

Namespace

Drupal\webform_revisions\Routing
View source
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    $latest_revision_routes = [
      'entity.webform.source_form',
      'entity.webform.edit_form',
      'entity.webform_ui.element',
      'entity.webform_ui.change_element',
      'entity.webform_ui.element.add_form',
      'entity.webform_ui.element.add_page',
      'entity.webform_ui.element.add_layout',
      'entity.webform_ui.element.edit_form',
      'entity.webform_ui.element.delete_form',
      'entity.webform_ui.element.duplicate_form',
      'entity.webform_ui.element.test_form',
    ];
    foreach ($latest_revision_routes as $route_name) {
      if ($route = $collection
        ->get($route_name)) {
        $current = $route
          ->getOption('parameters') ?: [];
        $current['webform']['load_latest_revision'] = TRUE;
        $route
          ->setOption('parameters', $current);
      }
    }
  }

}

Members

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