Skip to content

Route Altering

Willi edited this page Apr 16, 2018 · 1 revision

my_module/src/Routing/myRouteSubscriber.php

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

class myRouteSubscriber extends RouteSubscriberBase {

  protected function alterRoutes(RouteCollection $collection) {

    if ($route = $collection->get('<route>')) {
      $defaults = $route->getDefaults();
      $defaults['_form'] = ... ;
      $route->setDefaults($defaults);
    }
  }

}