Chris@0: requestStack = $request_stack; Chris@0: $this->account = $account; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Selects the block place override of the block page display variant. Chris@0: * Chris@0: * @param \Drupal\Core\Render\PageDisplayVariantSelectionEvent $event Chris@0: * The event to process. Chris@0: */ Chris@0: public function onBlockPageDisplayVariantSelected(PageDisplayVariantSelectionEvent $event) { Chris@0: if ($event->getPluginId() === 'block_page') { Chris@0: if ($this->requestStack->getCurrentRequest()->query->has('block-place') && $this->account->hasPermission('administer blocks')) { Chris@0: $event->setPluginId('block_place_page'); Chris@0: } Chris@0: $event->addCacheContexts(['user.permissions', 'url.query_args']); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public static function getSubscribedEvents() { Chris@0: // Set a very low priority, so that it runs last. Chris@0: $events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = ['onBlockPageDisplayVariantSelected', -1000]; Chris@0: return $events; Chris@0: } Chris@0: Chris@0: }