diff --git a/core/lib/Drupal/Core/Access/AccessDependentTrait.php b/core/lib/Drupal/Core/Access/AccessDependentTrait.php deleted file mode 100644 index 94f2c93d95..0000000000 --- a/core/lib/Drupal/Core/Access/AccessDependentTrait.php +++ /dev/null @@ -1,32 +0,0 @@ -accessDependency = $access_dependency; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getAccessDependency() { - return $this->accessDependency; - } - -} diff --git a/core/lib/Drupal/Core/Access/AccessDependentInterface.php b/core/lib/Drupal/Core/Access/DependentAccessInterface.php similarity index 75% rename from core/lib/Drupal/Core/Access/AccessDependentInterface.php rename to core/lib/Drupal/Core/Access/DependentAccessInterface.php index a8386282e9..7611ecfcd0 100644 --- a/core/lib/Drupal/Core/Access/AccessDependentInterface.php +++ b/core/lib/Drupal/Core/Access/DependentAccessInterface.php @@ -20,24 +20,24 @@ * $accessible->getAccessDependency()->access($op, $account, TRUE); * @endcode */ -interface AccessDependentInterface { +interface DependentAccessInterface { /** * Sets the access dependency. * - * @param \Drupal\Core\Access\AccessibleInterface $access_dependency - * The object upon which access depends. + * @param \Drupal\Core\Access\AccessibleInterface[] $access_dependencies + * The access dependencies. * * @return $this */ - public function setAccessDependency(AccessibleInterface $access_dependency); + public function setAccessDependencies(array $access_dependencies); /** - * Gets the access dependency. + * Gets the access dependencies. * - * @return \Drupal\Core\Access\AccessibleInterface|null + * @return \Drupal\Core\Access\AccessibleInterface[] * The access dependency or NULL if none has been set. */ - public function getAccessDependency(); + public function getAccessDependencies(); } diff --git a/core/lib/Drupal/Core/Access/DependentAccessTrait.php b/core/lib/Drupal/Core/Access/DependentAccessTrait.php new file mode 100644 index 0000000000..1f6a5b57ce --- /dev/null +++ b/core/lib/Drupal/Core/Access/DependentAccessTrait.php @@ -0,0 +1,32 @@ +accessDependencies = $access_dependencies; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getAccessDependencies() { + return $this->accessDependencies; + } + +} diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module index 44a69579cd..f63d938f1e 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -119,11 +119,10 @@ function block_content_add_body_field($block_type_id, $label = 'Body') { * 'reusable' is explicitly set. * * Block_content entities that are reusable should by default not be selectable - * as entity reference values. A module can still - * create an instance of + * as entity reference values. A module can still create an instance of * \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface - * that will will allow selection of non-reusable blocks by explicitly setting - * a condition on either the 'reusable' field. + * that will allow selection of non-reusable blocks by explicitly setting + * a condition on the 'reusable' field. * * @see \Drupal\block_content\BlockContentAccessControlHandler */ @@ -131,7 +130,6 @@ function block_content_query_entity_reference_alter(AlterableInterface $query) { if ($query instanceof SelectInterface && $query->getMetaData('entity_type') === 'block_content' && $query->hasTag('block_content_access')) { $data_table = \Drupal::entityTypeManager()->getDefinition('block_content')->getDataTable(); if (array_key_exists($data_table, $query->getTables()) && !_block_content_has_reusable_condition($query->conditions(), $query->getTables())) { - // If no reusable condition create a condition set to TRUE. $query->condition("$data_table.reusable", TRUE); } } @@ -140,6 +138,9 @@ function block_content_query_entity_reference_alter(AlterableInterface $query) { /** * Utility function to find nested conditions using the reusable field. * + * @todo Replace this a function to a call to the API in + * https://www.drupal.org/project/drupal/issues/2984930 + * * @param array $condition * The condition or condition group to check. * @param array $tables diff --git a/core/modules/block_content/block_content.post_update.php b/core/modules/block_content/block_content.post_update.php index 3ad95643bd..6587658d49 100644 --- a/core/modules/block_content/block_content.post_update.php +++ b/core/modules/block_content/block_content.post_update.php @@ -8,7 +8,7 @@ use Drupal\Core\Config\Entity\ConfigEntityUpdater; /** - * Adds a 'reusable' filter to Custom Block views. + * Adds a 'reusable' filter to all Custom Block views. */ function block_content_post_update_add_views_reusable_filter(&$sandbox = NULL) { $data_table = \Drupal::entityTypeManager() diff --git a/core/modules/block_content/src/BlockContentAccessControlHandler.php b/core/modules/block_content/src/BlockContentAccessControlHandler.php index c7138c0238..23e12bffed 100644 --- a/core/modules/block_content/src/BlockContentAccessControlHandler.php +++ b/core/modules/block_content/src/BlockContentAccessControlHandler.php @@ -2,8 +2,8 @@ namespace Drupal\block_content; -use Drupal\block_content\Event\BlockContentGetDependencyEvent; -use Drupal\Core\Access\AccessDependentInterface; +use Drupal\block_content\Event\BlockContentGetDependenciesEvent; +use Drupal\Core\Access\DependentAccessInterface; use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\EntityHandlerInterface; use Drupal\Core\Entity\EntityInterface; @@ -63,24 +63,24 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter } /** @var \Drupal\block_content\BlockContentInterface $entity */ if ($entity->isReusable() === FALSE) { - if (!$entity instanceof AccessDependentInterface) { - throw new \LogicException("Non-reusable block entities must implement \Drupal\Core\Access\AccessDependentInterface for access control."); + if (!$entity instanceof DependentAccessInterface) { + throw new \LogicException("Non-reusable block entities must implement \Drupal\Core\Access\DependentAccessInterface for access control."); } - $dependency = $entity->getAccessDependency(); - if (empty($dependency)) { - // If an access dependency has not been set let modules set one. - $event = new BlockContentGetDependencyEvent($entity); - $this->eventDispatcher->dispatch(BlockContentEvents::INLINE_BLOCK_GET_DEPENDENCY, $event); - $dependency = $entity->getAccessDependency(); - if (empty($dependency)) { + $dependencies = $entity->getAccessDependencies(); + if (empty($dependencies)) { + // If access dependencies have not been set let modules set them. + $event = new BlockContentGetDependenciesEvent($entity); + $this->eventDispatcher->dispatch(BlockContentEvents::BLOCK_CONTENT_GET_DEPENDENCIES, $event); + $dependencies = $entity->getAccessDependencies(); + if (empty($dependencies)) { return AccessResult::forbidden("Non-reusable blocks must set an access dependency for access control."); } } - if (empty($dependency->in_preview)) { - /** @var \Drupal\Core\Entity\EntityInterface $dependency */ - $access = $access->andIf($dependency->access($operation, $account, TRUE)); + foreach ($dependencies as $dependency) { + if (empty($dependency->in_preview)) { + $access = $access->andIf($dependency->access($operation, $account, TRUE)); + } } - } return $access; } diff --git a/core/modules/block_content/src/BlockContentEvents.php b/core/modules/block_content/src/BlockContentEvents.php index 865c07aa98..2f5de4c161 100644 --- a/core/modules/block_content/src/BlockContentEvents.php +++ b/core/modules/block_content/src/BlockContentEvents.php @@ -5,24 +5,24 @@ /** * Defines events for the block_content module. * - * @see \Drupal\block_content\Event\BlockContentGetDependencyEvent + * @see \Drupal\block_content\Event\BlockContentGetDependenciesEvent */ final class BlockContentEvents { /** - * Name of the event when getting the dependency of a non-reusable block. + * Name of the event when getting the dependencies of a non-reusable block. * - * This event allows modules to set a dependency of non-reusable block if - * \Drupal\Core\Access\AccessDependentTrait::getAccessDependency has not been - * called. + * This event allows modules to set the dependencies of non-reusable block if + * \Drupal\block_content\Entity\BlockContent::setAccessDependencies has not + * been called. * * @Event * - * @see \Drupal\block_content\Event\BlockContentGetDependencyEvent + * @see \Drupal\block_content\Event\BlockContentGetDependenciesEvent * @see \Drupal\block_content\BlockContentAccessControlHandler::checkAccess() * * @var string */ - const INLINE_BLOCK_GET_DEPENDENCY = 'block_content.get_dependency'; + const BLOCK_CONTENT_GET_DEPENDENCIES = 'block_content.get_dependencies'; } diff --git a/core/modules/block_content/src/BlockContentInterface.php b/core/modules/block_content/src/BlockContentInterface.php index 50fabdfb1a..d926c4800f 100644 --- a/core/modules/block_content/src/BlockContentInterface.php +++ b/core/modules/block_content/src/BlockContentInterface.php @@ -2,7 +2,7 @@ namespace Drupal\block_content; -use Drupal\Core\Access\AccessDependentInterface; +use Drupal\Core\Access\DependentAccessInterface; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityChangedInterface; use Drupal\Core\Entity\EntityPublishedInterface; @@ -11,7 +11,7 @@ /** * Provides an interface defining a custom block entity. */ -interface BlockContentInterface extends ContentEntityInterface, EntityChangedInterface, RevisionLogInterface, EntityPublishedInterface, AccessDependentInterface { +interface BlockContentInterface extends ContentEntityInterface, EntityChangedInterface, RevisionLogInterface, EntityPublishedInterface, DependentAccessInterface { /** * Returns the block revision log message. @@ -60,12 +60,16 @@ public function isReusable(); /** * Sets the block to be reusable. * - * @param bool $reusable - * Whether the block should be reusable, defaults to TRUE. + * @return $this + */ + public function setReusable(); + + /** + * Sets the block to be non-reusable. * * @return $this */ - public function setReusable($reusable = TRUE); + public function setNonreusable(); /** * Sets the theme value. diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 2995e99cec..c90349dd22 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -2,7 +2,7 @@ namespace Drupal\block_content\Entity; -use Drupal\Core\Access\AccessDependentTrait; +use Drupal\Core\Access\DependentAccessTrait; use Drupal\Core\Entity\EditorialContentEntityBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; @@ -78,7 +78,7 @@ */ class BlockContent extends EditorialContentEntityBase implements BlockContentInterface { - use AccessDependentTrait; + use DependentAccessTrait; /** * The theme the block is being created in. @@ -312,8 +312,15 @@ public function isReusable() { /** * {@inheritdoc} */ - public function setReusable($reusable = TRUE) { - return $this->set('reusable', $reusable); + public function setReusable() { + return $this->set('reusable', TRUE); + } + + /** + * {@inheritdoc} + */ + public function setNonreusable() { + return $this->set('reusable', FALSE); } /** diff --git a/core/modules/block_content/src/Event/BlockContentGetDependencyEvent.php b/core/modules/block_content/src/Event/BlockContentGetDependenciesEvent.php similarity index 77% rename from core/modules/block_content/src/Event/BlockContentGetDependencyEvent.php rename to core/modules/block_content/src/Event/BlockContentGetDependenciesEvent.php index c0d7a730ac..fcfcf2ccf4 100644 --- a/core/modules/block_content/src/Event/BlockContentGetDependencyEvent.php +++ b/core/modules/block_content/src/Event/BlockContentGetDependenciesEvent.php @@ -6,9 +6,9 @@ use Symfony\Component\EventDispatcher\Event; /** - * Block content event to allow setting an access dependency. + * Block content event to allow setting access dependencies. */ -class BlockContentGetDependencyEvent extends Event { +class BlockContentGetDependenciesEvent extends Event { /** * The block content entity. @@ -17,13 +17,6 @@ class BlockContentGetDependencyEvent extends Event { */ protected $blockContent; - /** - * The dependency. - * - * @var \Drupal\Core\Access\AccessibleInterface - */ - protected $dependency; - /** * BlockContentGetDependencyEvent constructor. * diff --git a/core/modules/block_content/tests/modules/block_content_view_override/config/install/views.view.block_content.yml b/core/modules/block_content/tests/modules/block_content_view_override/config/install/views.view.block_content.yml index 1c95f9f854..3c622a9abb 100644 --- a/core/modules/block_content/tests/modules/block_content_view_override/config/install/views.view.block_content.yml +++ b/core/modules/block_content/tests/modules/block_content_view_override/config/install/views.view.block_content.yml @@ -468,7 +468,7 @@ display: - url - url.query_args - user.permissions - max-age: -1 + max-age: 0 tags: { } page_1: display_plugin: page @@ -493,7 +493,7 @@ display: - url - url.query_args - user.permissions - max-age: -1 + max-age: 0 tags: { } page_2: display_plugin: page @@ -592,7 +592,7 @@ display: groups: 1: AND cache_metadata: - max-age: -1 + max-age: 0 contexts: - 'languages:language_content' - 'languages:language_interface' diff --git a/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php b/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php index d0c1462740..142dd79500 100644 --- a/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php +++ b/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php @@ -94,15 +94,14 @@ protected function setUp() { * * @dataProvider providerTestAccess */ - public function testAccess($published, $reusable, $permissions, $parent_access, $expected_access) { + public function testAccess($operation, $published, $reusable, $permissions, $parent_access, $expected_access) { $published ? $this->blockEntity->setPublished() : $this->blockEntity->setUnpublished(); - $this->blockEntity->setReusable($reusable); + $reusable ? $this->blockEntity->setReusable() : $this->blockEntity->setNonreusable(); $user = User::create([ 'name' => 'Someone', 'mail' => 'hi@example.com', ]); - $user->save(); if ($permissions) { foreach ($permissions as $permission) { @@ -129,16 +128,16 @@ public function testAccess($published, $reusable, $permissions, $parent_access, $expected_parent_result = AccessResult::forbidden(); break; } - $parent_entity->access('view', $user, TRUE) + $parent_entity->access($operation, $user, TRUE) ->willReturn($expected_parent_result) ->shouldBeCalled(); - $this->blockEntity->setAccessDependency($parent_entity->reveal()); + $this->blockEntity->setAccessDependencies([$parent_entity->reveal()]); } $this->blockEntity->save(); - $result = $this->accessControlHandler->access($this->blockEntity, 'view', $user, TRUE); + $result = $this->accessControlHandler->access($this->blockEntity, $operation, $user, TRUE); switch ($expected_access) { case 'allowed': $this->assertTrue($result->isAllowed()); @@ -161,57 +160,65 @@ public function testAccess($published, $reusable, $permissions, $parent_access, * Dataprovider for testAccess(). */ public function providerTestAccess() { - return [ - 'published:reusable' => [ + $cases = [ + 'view:published:reusable' => [ + 'view', TRUE, TRUE, [], NULL, 'allowed', ], - 'unpublished:reusable' => [ + 'view:unpublished:reusable' => [ + 'view', FALSE, TRUE, [], NULL, 'neutral', ], - 'unpublished:reusable:admin' => [ + 'view:unpublished:reusable:admin' => [ + 'view', FALSE, TRUE, ['administer blocks'], NULL, 'allowed', ], - 'published:reusable:admin' => [ + 'view:published:reusable:admin' => [ + 'view', TRUE, TRUE, ['administer blocks'], NULL, 'allowed', ], - 'published:non_reusable' => [ + 'view:published:non_reusable' => [ + 'view', TRUE, FALSE, [], NULL, 'forbidden', ], - 'published:non_reusable:parent_allowed' => [ + 'view:published:non_reusable:parent_allowed' => [ + 'view', TRUE, FALSE, [], 'allowed', 'allowed', ], - 'published:non_reusable:parent_neutral' => [ + 'view:published:non_reusable:parent_neutral' => [ + 'view', TRUE, FALSE, [], 'neutral', 'neutral', ], - 'published:non_reusable:parent_forbidden' => [ + 'view:published:non_reusable:parent_forbidden' => [ + 'view', TRUE, FALSE, [], @@ -219,6 +226,75 @@ public function providerTestAccess() { 'forbidden', ], ]; + foreach (['update', 'delete'] as $operation) { + $cases += [ + $operation . ':published:reusable' => [ + $operation, + TRUE, + TRUE, + [], + NULL, + 'neutral', + ], + $operation . ':unpublished:reusable' => [ + $operation, + FALSE, + TRUE, + [], + NULL, + 'neutral', + ], + $operation . ':unpublished:reusable:admin' => [ + $operation, + FALSE, + TRUE, + ['administer blocks'], + NULL, + 'allowed', + ], + $operation . ':published:reusable:admin' => [ + $operation, + TRUE, + TRUE, + ['administer blocks'], + NULL, + 'allowed', + ], + $operation . ':published:non_reusable' => [ + $operation, + TRUE, + FALSE, + [], + NULL, + 'forbidden', + ], + $operation . ':published:non_reusable:parent_allowed' => [ + $operation, + TRUE, + FALSE, + [], + 'allowed', + 'neutral', + ], + $operation . ':published:non_reusable:parent_neutral' => [ + $operation, + TRUE, + FALSE, + [], + 'neutral', + 'neutral', + ], + $operation . ':published:non_reusable:parent_forbidden' => [ + $operation, + TRUE, + FALSE, + [], + 'forbidden', + 'forbidden', + ], + ]; + return $cases; + } } } diff --git a/core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php b/core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php index 600fc75fab..ddb20ffbd2 100644 --- a/core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php +++ b/core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php @@ -55,7 +55,7 @@ public function testReusableBlocksOnlyAreDerived() { $this->assertTrue($block_manager->hasDefinition($plugin_id)); // Set the block not to be reusable. - $block_content->setReusable(FALSE); + $block_content->setNonreusable(); $block_content->save(); // Ensure the non-reusable block content is not provided a derivative block diff --git a/core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php b/core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php index 725abf2603..e593336fa3 100644 --- a/core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php +++ b/core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php @@ -92,7 +92,6 @@ public function setUp() { 'type' => 'spiffy', 'reusable' => FALSE, ]); - $this->blockNonReusable->setReusable(FALSE); $this->blockNonReusable->save(); $configuration = [ @@ -146,7 +145,7 @@ public function testNoConditions() { $this->selectionHandler->getReferenceableEntities() ); - $this->blockNonReusable->setReusable(TRUE); + $this->blockNonReusable->setReusable(); $this->blockNonReusable->save(); // Ensure that the block is now returned as a referenceable entity. diff --git a/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php b/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php index fc3818bf31..2e998f020a 100644 --- a/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php +++ b/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php @@ -2,7 +2,7 @@ namespace Drupal\layout_builder\EventSubscriber; -use Drupal\Core\Access\AccessDependentInterface; +use Drupal\Core\Access\DependentAccessInterface; use Drupal\Core\Access\AccessResult; use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Session\AccountInterface; @@ -58,13 +58,13 @@ public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) { } // Set block access dependency even if we are not checking access on - // this level. The block itself may render another AccessDependentInterface + // this level. The block itself may render another DependentAccessInterface // object and need to pass on this value. - if ($block instanceof AccessDependentInterface) { + if ($block instanceof DependentAccessInterface) { $contexts = $event->getContexts(); if (isset($contexts['layout_builder.entity'])) { if ($entity = $contexts['layout_builder.entity']->getContextValue()) { - $block->setAccessDependency($entity); + $block->setAccessDependencies([$entity]); } } } diff --git a/core/modules/layout_builder/src/EventSubscriber/SetInlineBlockDependency.php b/core/modules/layout_builder/src/EventSubscriber/SetInlineBlockDependency.php index d28f74ca01..6324655f22 100644 --- a/core/modules/layout_builder/src/EventSubscriber/SetInlineBlockDependency.php +++ b/core/modules/layout_builder/src/EventSubscriber/SetInlineBlockDependency.php @@ -4,7 +4,7 @@ use Drupal\block_content\BlockContentEvents; use Drupal\block_content\BlockContentInterface; -use Drupal\block_content\Event\BlockContentGetDependencyEvent; +use Drupal\block_content\Event\BlockContentGetDependenciesEvent; use Drupal\Core\Database\Connection; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityInterface; @@ -86,20 +86,20 @@ public static function create(ContainerInterface $container) { */ public static function getSubscribedEvents() { return [ - BlockContentEvents::INLINE_BLOCK_GET_DEPENDENCY => 'onGetDependency', + BlockContentEvents::BLOCK_CONTENT_GET_DEPENDENCIES => 'onGetDependency', ]; } /** * Handles the BlockContentEvents::INLINE_BLOCK_GET_DEPENDENCY event. * - * @param \Drupal\block_content\Event\BlockContentGetDependencyEvent $event + * @param \Drupal\block_content\Event\BlockContentGetDependenciesEvent $event * The event. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ - public function onGetDependency(BlockContentGetDependencyEvent $event) { + public function onGetDependency(BlockContentGetDependenciesEvent $event) { $this->setLayoutDependency($event->getBlockContent()); } @@ -121,7 +121,7 @@ public function onGetDependency(BlockContentGetDependencyEvent $event) { * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ public function setLayoutDependency(BlockContentInterface $block_content) { - if ($block_content->isReusable() || $block_content->getAccessDependency()) { + if ($block_content->isReusable() || $block_content->getAccessDependencies()) { // If the block is reusable or if the block already has its dependency set // then there is nothing to do here. return; @@ -138,14 +138,14 @@ public function setLayoutDependency(BlockContentInterface $block_content) { $layout_entity = $layout_entity_storage->load($layout_entity_info->layout_entity_id); if ($this->isLayoutCompatibleEntity($layout_entity)) { if (!$layout_entity->getEntityType()->isRevisionable()) { - $block_content->setAccessDependency($layout_entity); + $block_content->setAccessDependencies([$layout_entity]); return; } foreach ($this->getEntityRevisionIds($layout_entity) as $revision_id) { $revision = $layout_entity_storage->loadRevision($revision_id); $block_revision_ids = $this->getInBlockRevisionIdsInSection($this->getEntitySections($revision)); if (in_array($block_content->getRevisionId(), $block_revision_ids)) { - $block_content->setAccessDependency($revision); + $block_content->setAccessDependencies([$revision]); return; } } diff --git a/core/modules/layout_builder/src/Plugin/Block/InlineBlockContentBlock.php b/core/modules/layout_builder/src/Plugin/Block/InlineBlockContentBlock.php index 2dc2fdd9f1..f614c8d15f 100644 --- a/core/modules/layout_builder/src/Plugin/Block/InlineBlockContentBlock.php +++ b/core/modules/layout_builder/src/Plugin/Block/InlineBlockContentBlock.php @@ -3,8 +3,8 @@ namespace Drupal\layout_builder\Plugin\Block; use Drupal\Component\Utility\NestedArray; -use Drupal\Core\Access\AccessDependentInterface; -use Drupal\Core\Access\AccessDependentTrait; +use Drupal\Core\Access\DependentAccessInterface; +use Drupal\Core\Access\DependentAccessTrait; use Drupal\Core\Access\AccessResult; use Drupal\Core\Block\BlockBase; use Drupal\Core\Entity\Entity\EntityFormDisplay; @@ -26,9 +26,9 @@ * deriver = "Drupal\layout_builder\Plugin\Derivative\InlineBlockContentDeriver", * ) */ -class InlineBlockContentBlock extends BlockBase implements ContainerFactoryPluginInterface, AccessDependentInterface { +class InlineBlockContentBlock extends BlockBase implements ContainerFactoryPluginInterface, DependentAccessInterface { - use AccessDependentTrait; + use DependentAccessTrait; /** * The entity type manager service. @@ -228,8 +228,8 @@ protected function getEntity() { ]); } } - if ($this->blockContent instanceof AccessDependentInterface && $dependee = $this->getAccessDependency()) { - $this->blockContent->setAccessDependency($dependee); + if ($this->blockContent instanceof DependentAccessInterface && $dependencies = $this->getAccessDependencies()) { + $this->blockContent->setAccessDependencies($dependencies); } return $this->blockContent; }