You are here

public function BlockPlaceEventSubscriber::onBlockPageDisplayVariantSelected in Drupal 8

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',
    ]);
  }
}