You are here

public function EventSubscriber::alterRoutes in JS Callback Handler 8.3

Alters existing routes for a specific collection.

Parameters

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

Overrides RouteSubscriberBase::alterRoutes

File

src/EventSubscriber.php, line 46

Class

EventSubscriber
RouteSubscriber.

Namespace

Drupal\js

Code

public function alterRoutes(RouteCollection $collection) {

  // Change the  '/js' endpoint to something else.
  if (($endpoint = \Drupal::config('js.settings')
    ->get('endpoint')) && $endpoint !== '/js' && ($route = $collection
    ->get('js.callback'))) {
    $route
      ->setPath($endpoint);
  }
}