You are here

protected function RouteSubscriber::alterRoutes in Lightning Workflow 8.3

Same name and namespace in other branches
  1. 8 src/Routing/RouteSubscriber.php \Drupal\lightning_workflow\Routing\RouteSubscriber::alterRoutes()
  2. 8.2 src/Routing/RouteSubscriber.php \Drupal\lightning_workflow\Routing\RouteSubscriber::alterRoutes()

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 22

Class

RouteSubscriber
Reacts to routing events.

Namespace

Drupal\lightning_workflow\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  $route = $collection
    ->get('panelizer.panels_ipe.revert_to_default');
  if ($route) {
    $route
      ->setDefault('_controller', PanelizerIPEController::class . '::revertToDefault');
  }

  // Ensure that certain routes use the latest revision, rather than the
  // default revision. This can be removed when
  // https://www.drupal.org/project/drupal/issues/2815221 is in core.
  $load_latest_revision = function ($route) use ($collection) {
    $route = $collection
      ->get($route);
    if ($route) {
      $parameters = $route
        ->getOption('parameters');
      $parameters['entity']['load_latest_revision'] = TRUE;
      $route
        ->setOption('parameters', $parameters);
    }
  };
  $load_latest_revision('editor.field_untransformed_text');
  $load_latest_revision('image.upload');
  $load_latest_revision('image.info');
  $load_latest_revision('quickedit.field_form');
}