You are here

protected function RouteSubscriber::alterRoutes in Panopoly Magic 8.2

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 16

Class

RouteSubscriber
Implements a route subscriber for Panopoly Magic.

Namespace

Drupal\panopoly_magic\Routing

Code

protected function alterRoutes(RouteCollection $collection) {

  // Replace the layout builder choose block route with our own.
  if ($route = $collection
    ->get('layout_builder.choose_block')) {
    $route
      ->setDefaults([
      '_controller' => '\\Drupal\\panopoly_magic\\Controller\\LayoutBuilderChooseBlockController::build',
      '_title' => $route
        ->getDefault('title'),
    ]);
  }
  if ($route = $collection
    ->get('layout_builder.choose_inline_block')) {
    $route
      ->setDefaults([
      '_controller' => '\\Drupal\\panopoly_magic\\Controller\\LayoutBuilderChooseBlockController::inlineBlockList',
      '_title' => $route
        ->getDefault('title'),
    ]);
  }

  // Replace the layout builder add block route with our own.
  if ($route = $collection
    ->get('layout_builder.add_block')) {
    $route
      ->setDefaults([
      '_controller' => '\\Drupal\\panopoly_magic\\Controller\\LayoutBuilderAddBlockController::addBlock',
      '_title' => $route
        ->getDefault('title'),
    ]);
  }

  // Replace the layout builder update block form with our own.
  if ($route = $collection
    ->get('layout_builder.update_block')) {
    $route
      ->setDefault('_form', '\\Drupal\\panopoly_magic\\Form\\LayoutBuilderUpdateBlockForm');
  }
}