diff --git a/core/modules/content_moderation/content_moderation.module b/core/modules/content_moderation/content_moderation.module index c86992bc61..8e3f31733d 100644 --- a/core/modules/content_moderation/content_moderation.module +++ b/core/modules/content_moderation/content_moderation.module @@ -30,6 +30,7 @@ use Drupal\Core\Action\Plugin\Action\PublishAction; use Drupal\Core\Action\Plugin\Action\UnpublishAction; use Drupal\workflows\Entity\Workflow; +use Drupal\workspaces\WorkspaceInterface; use Drupal\views\Entity\View; /** @@ -280,7 +281,7 @@ function content_moderation_entity_field_access($operation, FieldDefinitionInter * Prevents a workspace to be published if there are any pending revisions in a * moderation state that doesn't create default revisions. */ -function content_moderation_workspace_access(EntityInterface $entity, $operation, AccountInterface $account) { +function content_moderation_workspace_access(WorkspaceInterface $workspace, $operation, AccountInterface $account) { if ($operation !== 'publish') { return AccessResult::neutral(); } @@ -289,7 +290,7 @@ function content_moderation_workspace_access(EntityInterface $entity, $operation $workspace_association = \Drupal::service('workspaces.association'); $entity_type_manager = \Drupal::entityTypeManager(); - $tracked_revisions = $workspace_association->getTrackedEntities($entity->id()); + $tracked_revisions = $workspace_association->getTrackedEntities($workspace->id()); // Extract all the second-level keys (revision IDs) of the two-dimensional // array. $tracked_revision_ids = array_reduce(array_map('array_keys', $tracked_revisions), 'array_merge', []); @@ -327,7 +328,7 @@ function content_moderation_workspace_access(EntityInterface $entity, $operation if ($count = $query->count()->execute()) { $message = \Drupal::translation()->formatPlural($count, 'The @label workspace can not be published because it contains 1 item in an unpublished moderation state.', 'The @label workspace can not be published because it contains @count items in an unpublished moderation state.', [ - '@label' => $entity->label(), + '@label' => $workspace->label(), ]); return AccessResult::forbidden((string) $message); } diff --git a/core/modules/workspaces/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php b/core/modules/content_moderation/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php similarity index 93% rename from core/modules/workspaces/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php rename to core/modules/content_moderation/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php index 5445873c2c..2227c2dac5 100644 --- a/core/modules/workspaces/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php +++ b/core/modules/content_moderation/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php @@ -1,8 +1,8 @@ getStorage('node'); - $stage = Workspace::load('stage'); $this->switchToWorkspace($stage); diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php index b07881c277..fcf4d06c44 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php @@ -276,7 +276,7 @@ public function testContentModerationStateTranslationDataRemoval($entity_type_id /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $this->createEntity($entity_type_id, 'published'); $langcode = 'fr'; - $translation = $entity->addTranslation($langcode, ['title' => 'Titolo test']); + $translation = $entity->addTranslation($langcode, ['title' => 'French title test']); // Make sure we add values for all of the required fields. if ($entity_type_id == 'block_content') { $translation->info = $this->randomString(); diff --git a/core/modules/workspaces/tests/src/Kernel/WorkspacesContentModerationStateTest.php b/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php similarity index 98% rename from core/modules/workspaces/tests/src/Kernel/WorkspacesContentModerationStateTest.php rename to core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php index 3026c14f33..09e6cdbcd7 100644 --- a/core/modules/workspaces/tests/src/Kernel/WorkspacesContentModerationStateTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php @@ -1,13 +1,13 @@