diff --git a/core/modules/workspace/src/EntityOperations.php b/core/modules/workspace/src/EntityOperations.php index d954afe..7137d78 100644 --- a/core/modules/workspace/src/EntityOperations.php +++ b/core/modules/workspace/src/EntityOperations.php @@ -145,7 +145,7 @@ public function entityPresave(EntityInterface $entity) { // Disallow any change to an unsupported entity when we are not in the // default workspace. if (!$this->workspaceManager->isEntityTypeSupported($entity_type)) { - throw new WorkspaceStorageException('This entity can only be saved in the default workspace.'); + throw new \RuntimeException('This entity can only be saved in the default workspace.'); } /** @var \Drupal\Core\Entity\RevisionableInterface|\Drupal\Core\Entity\EntityPublishedInterface $entity */ @@ -251,7 +251,7 @@ public function entityPredelete(EntityInterface $entity) { // Disallow any change to an unsupported entity when we are not in the // default workspace. if (!$this->workspaceManager->isEntityTypeSupported($entity_type)) { - throw new WorkspaceStorageException('This entity can only be deleted in the default workspace.'); + throw new \RuntimeException('This entity can only be deleted in the default workspace.'); } } @@ -357,6 +357,8 @@ public function formAlter(array &$form, FormStateInterface $form_state, $form_id * Validation handler for forms that do not handle a supported entity type. */ public function validateForm(array &$form, FormStateInterface $form_state) { + // The exception in ::entityPresave() is thrown upon submission of the form, + // at which point we can longer transform it into a valiation error. $form_state->setError($form, $this->t('This form can only be submitted in the default workspace.')); } diff --git a/core/modules/workspace/src/WorkspaceStorageException.php b/core/modules/workspace/src/WorkspaceStorageException.php deleted file mode 100644 index a4a76f3..0000000 --- a/core/modules/workspace/src/WorkspaceStorageException.php +++ /dev/null @@ -1,10 +0,0 @@ -name->value = 'stage entity_test_mulrev'; $entity_test->setNewRevision(TRUE); - $this->expectException(WorkspaceStorageException::class); + $this->expectException(EntityStorageException::class); $this->expectExceptionMessage('This entity can only be saved in the default workspace.'); $entity_test->save(); @@ -481,12 +481,12 @@ public function testDisallowedEntityCRUDInNonDefaultWorkspace() { $new_entity_test = EntityTestMulRev::create([ 'name' => 'stage entity_test_mulrev', ]); - $this->expectException(WorkspaceStorageException::class); + $this->expectException(EntityStorageException::class); $this->expectExceptionMessage('This entity can only be saved in the default workspace.'); $new_entity_test->save(); // Check deleting an existing entity. - $this->expectException(WorkspaceStorageException::class); + $this->expectException(EntityStorageException::class); $this->expectExceptionMessage('This entity can only be deleted in the default workspace.'); $entity_test->delete(); }