diff --git a/core/modules/block_content/src/BlockContentAccessControlHandler.php b/core/modules/block_content/src/BlockContentAccessControlHandler.php index d0c19c5..e738b3f 100644 --- a/core/modules/block_content/src/BlockContentAccessControlHandler.php +++ b/core/modules/block_content/src/BlockContentAccessControlHandler.php @@ -19,6 +19,7 @@ class BlockContentAccessControlHandler extends EntityAccessControlHandler { */ protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view') { + return AccessResult::allowedIfHasPermission($account, 'administer blocks'); return AccessResult::allowed(); } return parent::checkAccess($entity, $operation, $account); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/BlockContent/BlockContentResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/BlockContent/BlockContentResourceTestBase.php index 4d30111..417dd0f 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/BlockContent/BlockContentResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/BlockContent/BlockContentResourceTestBase.php @@ -25,8 +25,6 @@ * {@inheritdoc} */ protected static $patchProtectedFieldNames = [ - 'id', - 'revision_id', 'changed', ]; @@ -46,13 +44,15 @@ protected function setUpAuthorization($method) { * {@inheritdoc} */ protected function createEntity() { - $block_content_type = BlockContentType::create([ - 'id' => 'basic', - 'label' => 'basic', - 'revision' => FALSE, - ]); - $block_content_type->save(); - block_content_add_body_field($block_content_type->id()); + if (!BlockContentType::load('basic')) { + $block_content_type = BlockContentType::create([ + 'id' => 'basic', + 'label' => 'basic', + 'revision' => TRUE, + ]); + $block_content_type->save(); + block_content_add_body_field($block_content_type->id()); + } // Create a "Llama" custom block. $block_content = BlockContent::create([ @@ -63,11 +63,7 @@ protected function createEntity() { 'format' => 'plain_text', ], ]); - - $block_content->setChangedTime(123456789) - ->setRevisionCreationTime(123456789) - ->save(); - + $block_content->save(); return $block_content; } @@ -144,7 +140,18 @@ protected function getExpectedNormalizedEntity() { * {@inheritdoc} */ protected function getNormalizedPostEntity() { - return []; + return [ + 'type' => [ + [ + 'target_id' => 'basic', + ], + ], + 'info' => [ + [ + 'value' => 'Llama & ' . $this->randomMachineName(), + ], + ], + ]; } }