You are here

public function BlockPageDisplayVariantSubscriber::onSelectPageDisplayVariant in Context 8.4

Same name and namespace in other branches
  1. 8 src/EventSubscriber/BlockPageDisplayVariantSubscriber.php \Drupal\context\EventSubscriber\BlockPageDisplayVariantSubscriber::onSelectPageDisplayVariant()
  2. 8.0 src/EventSubscriber/BlockPageDisplayVariantSubscriber.php \Drupal\context\EventSubscriber\BlockPageDisplayVariantSubscriber::onSelectPageDisplayVariant()

Selects the context block page display variant.

Parameters

\Drupal\Core\Render\PageDisplayVariantSelectionEvent $event: The event to process.

File

src/EventSubscriber/BlockPageDisplayVariantSubscriber.php, line 41

Class

BlockPageDisplayVariantSubscriber
Selects the block page display variant.

Namespace

Drupal\context\EventSubscriber

Code

public function onSelectPageDisplayVariant(PageDisplayVariantSelectionEvent $event) {

  // Activate the context block page display variant if any of the reactions
  // is a blocks reaction.
  foreach ($this->contextManager
    ->getActiveReactions() as $reaction) {
    if ($reaction instanceof Blocks) {
      $event
        ->setPluginId('context_block_page');
      break;
    }
  }
}