class BlockPageDisplayVariantSubscriber in Context 8
Same name and namespace in other branches
- 8.4 src/EventSubscriber/BlockPageDisplayVariantSubscriber.php \Drupal\context\EventSubscriber\BlockPageDisplayVariantSubscriber
- 8.0 src/EventSubscriber/BlockPageDisplayVariantSubscriber.php \Drupal\context\EventSubscriber\BlockPageDisplayVariantSubscriber
Selects the block page display variant.
Hierarchy
- class \Drupal\context\EventSubscriber\BlockPageDisplayVariantSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of BlockPageDisplayVariantSubscriber
See also
\Drupal\block\Plugin\DisplayVariant\BlockPageVariant
1 string reference to 'BlockPageDisplayVariantSubscriber'
1 service uses BlockPageDisplayVariantSubscriber
File
- src/
EventSubscriber/ BlockPageDisplayVariantSubscriber.php, line 21 - Contains \Drupal\context\EventSubscriber\BlockPageDisplayVariantSubscriber.
Namespace
Drupal\context\EventSubscriberView source
class BlockPageDisplayVariantSubscriber implements EventSubscriberInterface {
/**
* @var \Drupal\context\ContextManager
*/
private $contextManager;
/**
* @param \Drupal\context\ContextManager $contextManager
*/
function __construct(ContextManager $contextManager) {
$this->contextManager = $contextManager;
}
/**
* Selects the context block page display variant.
*
* @param \Drupal\Core\Render\PageDisplayVariantSelectionEvent $event
* The event to process.
*/
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;
}
}
}
/**
* {@inheritdoc}
*/
static function getSubscribedEvents() {
$events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = array(
'onSelectPageDisplayVariant',
);
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlockPageDisplayVariantSubscriber:: |
private | property | ||
BlockPageDisplayVariantSubscriber:: |
static | function | Returns an array of event names this subscriber wants to listen to. | |
BlockPageDisplayVariantSubscriber:: |
public | function | Selects the context block page display variant. | |
BlockPageDisplayVariantSubscriber:: |
function |