You are here

class VoyagerPageDisplayVariantSubscriber in GraphQL 8.3

Disables any display variant on the voyager page.

Hierarchy

Expanded class hierarchy of VoyagerPageDisplayVariantSubscriber

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

File

src/EventSubscriber/VoyagerPageDisplayVariantSubscriber.php, line 12

Namespace

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

  /**
   * Disables any display variant on the voyager page.
   *
   * @param \Drupal\Core\Render\PageDisplayVariantSelectionEvent $event
   *   The event to process.
   */
  public function onSelectPageDisplayVariant(PageDisplayVariantSelectionEvent $event) {
    if (strpos($event
      ->getRouteMatch()
      ->getRouteName(), 'graphql.voyager.') === 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
VoyagerPageDisplayVariantSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
VoyagerPageDisplayVariantSubscriber::onSelectPageDisplayVariant public function Disables any display variant on the voyager page.