You are here

class ExplorerPageDisplayVariantSubscriber in GraphQL 8.3

Same name and namespace in other branches
  1. 8 src/EventSubscriber/ExplorerPageDisplayVariantSubscriber.php \Drupal\graphql\EventSubscriber\ExplorerPageDisplayVariantSubscriber
  2. 8.2 src/EventSubscriber/ExplorerPageDisplayVariantSubscriber.php \Drupal\graphql\EventSubscriber\ExplorerPageDisplayVariantSubscriber

Disables any display variant on the explorer page.

Hierarchy

Expanded class hierarchy of ExplorerPageDisplayVariantSubscriber

1 string reference to 'ExplorerPageDisplayVariantSubscriber'
graphql.services.yml in ./graphql.services.yml
graphql.services.yml
1 service uses ExplorerPageDisplayVariantSubscriber
graphql.graphiql.page_display_variant_subscriber in ./graphql.services.yml
Drupal\graphql\EventSubscriber\ExplorerPageDisplayVariantSubscriber

File

src/EventSubscriber/ExplorerPageDisplayVariantSubscriber.php, line 12

Namespace

Drupal\graphql\EventSubscriber
View source
class ExplorerPageDisplayVariantSubscriber implements EventSubscriberInterface {

  /**
   * Disables any display variant on the explorer page.
   *
   * @param \Drupal\Core\Render\PageDisplayVariantSelectionEvent $event
   *   The event to process.
   */
  public function onSelectPageDisplayVariant(PageDisplayVariantSelectionEvent $event) {
    if (strpos($event
      ->getRouteMatch()
      ->getRouteName(), 'graphql.explorer.') === 0) {
      $event
        ->setPluginId(NULL)
        ->stopPropagation();
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events = [
      RenderEvents::SELECT_PAGE_DISPLAY_VARIANT => [
        [
          'onSelectPageDisplayVariant',
        ],
      ],
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExplorerPageDisplayVariantSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
ExplorerPageDisplayVariantSubscriber::onSelectPageDisplayVariant public function Disables any display variant on the explorer page.