diff --git a/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php b/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php index 4270a1fb53..8c9d20a638 100644 --- a/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php +++ b/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php @@ -97,6 +97,14 @@ public function get($index) { /** * {@inheritdoc} */ + public function isEmpty() { + $this->computeModerationFieldItemList(); + return parent::isEmpty(); + } + + /** + * {@inheritdoc} + */ public function getIterator() { $this->computeModerationFieldItemList(); return parent::getIterator(); diff --git a/core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php b/core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php index a0d46da428..37d05ec605 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php @@ -80,6 +80,13 @@ public function testArrayIteration() { } /** + * Test the moderation_state is not empty. + */ + public function testIsEmpty() { + $this->assertEquals(false, $this->testNode->moderation_state->isEmpty()); + } + + /** * Tests that moderation state changes also change the related entity state. */ public function testModerationStateChanges() {