class LBUXRouteAlter in Layout Builder UX 8
Alters the Layout Builder UI routes.
Hierarchy
- class \Drupal\lb_ux\Routing\LBUXRouteAlter implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of LBUXRouteAlter
1 string reference to 'LBUXRouteAlter'
1 service uses LBUXRouteAlter
File
- src/
Routing/ LBUXRouteAlter.php, line 13
Namespace
Drupal\lb_ux\RoutingView source
class LBUXRouteAlter implements EventSubscriberInterface {
/**
* Alters existing Layout Builder routes.
*
* @param \Drupal\Core\Routing\RouteBuildEvent $event
* The route build event.
*/
public function onAlterRoutes(RouteBuildEvent $event) {
$collection = $event
->getRouteCollection();
$route = $collection
->get('layout_builder.configure_section');
// Change the title callback for configuring sections.
$route
->setDefault('_title_callback', ConfigureSectionController::class . '::title');
// Copy the existing route to always display a section configuration form
// and give it a new path and route name. This will continue to be used when
// updating existing sections.
$new_route = clone $route;
$new_route
->setPath('/layout_builder/configure-form/section/{section_storage_type}/{section_storage}/{delta}/{plugin_id}');
$collection
->add('layout_builder.configure_section_form', $new_route);
// Change the existing route to use the auto-submit controller. This will be
// used when adding a new section.
$route
->setDefault('_controller', ConfigureSectionController::class . '::build');
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[RoutingEvents::ALTER] = 'onAlterRoutes';
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LBUXRouteAlter:: |
public static | function | ||
LBUXRouteAlter:: |
public | function | Alters existing Layout Builder routes. |