You are here

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'
lb_ux.services.yml in ./lb_ux.services.yml
lb_ux.services.yml
1 service uses LBUXRouteAlter
lb_ux.route_alter in ./lb_ux.services.yml
Drupal\lb_ux\Routing\LBUXRouteAlter

File

src/Routing/LBUXRouteAlter.php, line 13

Namespace

Drupal\lb_ux\Routing
View 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

Namesort descending Modifiers Type Description Overrides
LBUXRouteAlter::getSubscribedEvents public static function
LBUXRouteAlter::onAlterRoutes public function Alters existing Layout Builder routes.