diff --git a/core/modules/layout_builder/src/Access/LayoutBuilderAccessCheck.php b/core/modules/layout_builder/src/Access/LayoutBuilderAccessCheck.php index 033e153011..2668025e81 100644 --- a/core/modules/layout_builder/src/Access/LayoutBuilderAccessCheck.php +++ b/core/modules/layout_builder/src/Access/LayoutBuilderAccessCheck.php @@ -4,9 +4,7 @@ use Drupal\Core\Cache\RefinableCacheableDependencyInterface; use Drupal\Core\Routing\Access\AccessInterface; -use Drupal\Core\Session\AccountInterface; use Drupal\layout_builder\SectionStorageInterface; -use Symfony\Component\Routing\Route; /** * Provides an access check for the Layout Builder defaults. diff --git a/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php b/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php index d490bb1be4..656147e0db 100644 --- a/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\Context\EntityContext; -use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Drupal\field_ui\FieldUI; use Drupal\layout_builder\DefaultsSectionStorageInterface; @@ -447,7 +446,7 @@ public function getThirdPartyProviders() { * {@inheritdoc} */ public function routingAccess() { - return AccessResult::allowedIf($this->isLayoutBuilderEnabled()); + return AccessResult::allowedIf($this->isLayoutBuilderEnabled())->addCacheableDependency($this); } } diff --git a/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php b/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php index 88d15d4bb9..1d74b90dd5 100644 --- a/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\Context\EntityContext; -use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay; use Drupal\layout_builder\OverridesSectionStorageInterface; diff --git a/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php b/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php index 7c1b3425eb..8c9ae2737e 100644 --- a/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php @@ -114,7 +114,7 @@ public function getContextsDuringPreview() { * {@inheritdoc} */ public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { - @trigger_error('@todo', E_USER_DEPRECATED); + @trigger_error('\Drupal\layout_builder\SectionStorageInterface::access() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. \Drupal\layout_builder\SectionStorageInterface::routingAccess() should be used instead. See https://www.drupal.org/node/@todo.', E_USER_DEPRECATED); $result = $this->routingAccess(); return $return_as_object ? $result : $result->isAllowed(); } diff --git a/core/modules/layout_builder/src/SectionStorageInterface.php b/core/modules/layout_builder/src/SectionStorageInterface.php index 41a1055c72..52a48d8912 100644 --- a/core/modules/layout_builder/src/SectionStorageInterface.php +++ b/core/modules/layout_builder/src/SectionStorageInterface.php @@ -15,7 +15,7 @@ * experimental modules and development releases of contributed modules. * See https://www.drupal.org/core/experimental for more information. * - * @todo Remove AccessibleInterface + * @todo Remove AccessibleInterface from this interface. */ interface SectionStorageInterface extends SectionListInterface, PluginInspectionInterface, ContextAwarePluginInterface, AccessibleInterface { @@ -167,12 +167,18 @@ public function label(); public function save(); /** + * Determines access to this plugin during routing. + * * @return \Drupal\Core\Access\AccessResultInterface + * The access result. */ public function routingAccess(); /** + * Determines access to this plugin during rendering. + * * @return \Drupal\Core\Access\AccessResultInterface + * The access result. */ public function renderAccess(); diff --git a/core/modules/layout_builder/tests/modules/layout_builder_overrides_test/src/Plugin/SectionStorage/TestOverridesSectionStorage.php b/core/modules/layout_builder/tests/modules/layout_builder_overrides_test/src/Plugin/SectionStorage/TestOverridesSectionStorage.php index 6dca1ee900..39d33b13dc 100644 --- a/core/modules/layout_builder/tests/modules/layout_builder_overrides_test/src/Plugin/SectionStorage/TestOverridesSectionStorage.php +++ b/core/modules/layout_builder/tests/modules/layout_builder_overrides_test/src/Plugin/SectionStorage/TestOverridesSectionStorage.php @@ -3,7 +3,6 @@ namespace Drupal\layout_builder_overrides_test\Plugin\SectionStorage; use Drupal\Core\Access\AccessResult; -use Drupal\Core\Session\AccountInterface; use Drupal\layout_builder\Plugin\SectionStorage\SectionStorageBase; use Drupal\layout_builder\Section; use Drupal\layout_builder\SectionComponent; @@ -37,6 +36,13 @@ public function getSections() { * {@inheritdoc} */ public function routingAccess() { + return AccessResult::allowed(); + } + + /** + * {@inheritdoc} + */ + public function renderAccess() { return AccessResult::allowedIf(\Drupal::state()->get('layout_builder_overrides_test', FALSE))->setCacheMaxAge(0); } diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php index a280b7f028..2dbae56b3a 100644 --- a/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php +++ b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php @@ -186,11 +186,25 @@ public function getRedirectUrl() { * {@inheritdoc} */ public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { - @trigger_error('@todo', E_USER_DEPRECATED); + @trigger_error('\Drupal\layout_builder\SectionStorageInterface::access() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. \Drupal\layout_builder\SectionStorageInterface::routingAccess() should be used instead. See https://www.drupal.org/node/@todo.', E_USER_DEPRECATED); $result = $this->routingAccess(); return $return_as_object ? $result : $result->isAllowed(); } + /** + * {@inheritdoc} + */ + public function routingAccess() { + return AccessResult::allowed(); + } + + /** + * {@inheritdoc} + */ + public function renderAccess() { + return AccessResult::allowed(); + } + /** * {@inheritdoc} */ diff --git a/core/modules/layout_builder/tests/src/Kernel/DefaultsSectionStorageTest.php b/core/modules/layout_builder/tests/src/Kernel/DefaultsSectionStorageTest.php index ddb76cd23a..dde1577b27 100644 --- a/core/modules/layout_builder/tests/src/Kernel/DefaultsSectionStorageTest.php +++ b/core/modules/layout_builder/tests/src/Kernel/DefaultsSectionStorageTest.php @@ -58,7 +58,7 @@ protected function setUp() { * @dataProvider providerTestAccess * * @group legacy - * @expectedDeprecation @todo + * @expectedDeprecation \Drupal\layout_builder\SectionStorageInterface::access() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. \Drupal\layout_builder\SectionStorageInterface::routingAccess() should be used instead. See https://www.drupal.org/node/@todo. * * @param bool $expected * The expected outcome of ::access(). diff --git a/core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php b/core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php index d29687588a..dade9f2ca8 100644 --- a/core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php +++ b/core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php @@ -57,7 +57,7 @@ protected function setUp() { * @dataProvider providerTestAccess * * @group legacy - * @expectedDeprecation @todo + * @expectedDeprecation \Drupal\layout_builder\SectionStorageInterface::access() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. \Drupal\layout_builder\SectionStorageInterface::routingAccess() should be used instead. See https://www.drupal.org/node/@todo. * * @param bool $expected * The expected outcome of ::access().