You are here

class RouteSubscriber in Panopoly Magic 8.2

Implements a route subscriber for Panopoly Magic.

Hierarchy

  • class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of RouteSubscriber

1 string reference to 'RouteSubscriber'
panopoly_magic.services.yml in ./panopoly_magic.services.yml
panopoly_magic.services.yml
1 service uses RouteSubscriber
panopoly_magic.route_subscriber in ./panopoly_magic.services.yml
Drupal\panopoly_magic\Routing\RouteSubscriber

File

src/Routing/RouteSubscriber.php, line 11

Namespace

Drupal\panopoly_magic\Routing
View source
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  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');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1