function BlockPlaceEventSubscriber::onBlockPageDisplayVariantSelected

Selects the block place override of the block page display variant.

Parameters

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

File

core/modules/block_place/src/EventSubscriber/BlockPlaceEventSubscriber.php, line 49

Class

BlockPlaceEventSubscriber

Namespace

Drupal\block_place\EventSubscriber

Code

public function onBlockPageDisplayVariantSelected(PageDisplayVariantSelectionEvent $event) {
    if ($event->getPluginId() === 'block_page') {
        if ($this->requestStack
            ->getCurrentRequest()->query
            ->has('block-place') && $this->account
            ->hasPermission('administer blocks')) {
            $event->setPluginId('block_place_page');
        }
        $event->addCacheContexts([
            'user.permissions',
            'url.query_args',
        ]);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.