class BlockPageDisplayVariantSubscriber in Context groups 8
Same name and namespace in other branches
- 8.2 src/EventSubscriber/BlockPageDisplayVariantSubscriber.php \Drupal\context_groups\EventSubscriber\BlockPageDisplayVariantSubscriber
Class BlockPageDisplayVariantSubscriber.
@package Drupal\context_groups
Hierarchy
- class \Drupal\context_groups\EventSubscriber\BlockPageDisplayVariantSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of BlockPageDisplayVariantSubscriber
1 string reference to 'BlockPageDisplayVariantSubscriber'
1 service uses BlockPageDisplayVariantSubscriber
File
- src/
EventSubscriber/ BlockPageDisplayVariantSubscriber.php, line 16
Namespace
Drupal\context_groups\EventSubscriberView source
class BlockPageDisplayVariantSubscriber implements EventSubscriberInterface {
/**
* Drupal\context\ContextManager definition.
*
* @var \Drupal\context\ContextManager
*/
protected $contextManager;
/**
* Constructor.
*
* @param ContextManager $context_manager
* Context manager.
*/
public function __construct(ContextManager $context_manager) {
$this->contextManager = $context_manager;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = [
'onSelectPageDisplayVariant',
];
return $events;
}
/**
* Selects the context groups block page display variant.
*
* @param PageDisplayVariantSelectionEvent $event
* The event to process.
*/
public function onSelectPageDisplayVariant(PageDisplayVariantSelectionEvent $event) {
// Activate the context groups block page display variant.
foreach ($this->contextManager
->getActiveReactions() as $reaction) {
if ($reaction instanceof Blocks) {
$event
->setPluginId('context_groups_block_page');
break;
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlockPageDisplayVariantSubscriber:: |
protected | property | Drupal\context\ContextManager definition. | |
BlockPageDisplayVariantSubscriber:: |
public static | function | ||
BlockPageDisplayVariantSubscriber:: |
public | function | Selects the context groups block page display variant. | |
BlockPageDisplayVariantSubscriber:: |
public | function | Constructor. |