Commit 3f5c4fd9 authored by catch's avatar catch
Browse files

Issue #3491256 by amateescu: Improve the exception message for unsupported...

Issue #3491256 by amateescu: Improve the exception message for unsupported entity types in a workspace

(cherry picked from commit 2b63c15d)
parent a026efe5
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ public function entityPresave(EntityInterface $entity) {
    // Disallow any change to an unsupported entity when we are not in the
    // default workspace.
    if (!$this->workspaceInfo->isEntitySupported($entity)) {
      throw new \RuntimeException('This entity can only be saved in the default workspace.');
      throw new \RuntimeException(sprintf('The "%s" entity type can only be saved in the default workspace.', $entity->getEntityTypeId()));
    }

    /** @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\Core\Entity\EntityPublishedInterface $entity */
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public function testUnsupportedEntityTypes(): void {

    // Check that unsupported entity types can not be saved in a workspace.
    $this->expectException(EntityStorageException::class);
    $this->expectExceptionMessage('This entity can only be saved in the default workspace.');
    $this->expectExceptionMessage('The "entity_test" entity type can only be saved in the default workspace.');
    $entity->save();
  }

+2 −2
Original line number Diff line number Diff line
@@ -690,7 +690,7 @@ public function testDisallowedEntityCreateInNonDefaultWorkspace($entity_type_id,

    if (!$allowed) {
      $this->expectException(EntityStorageException::class);
      $this->expectExceptionMessage('This entity can only be saved in the default workspace.');
      $this->expectExceptionMessage("The \"$entity_type_id\" entity type can only be saved in the default workspace.");
    }
    $entity->save();
  }
@@ -721,7 +721,7 @@ public function testDisallowedEntityUpdateInNonDefaultWorkspace($entity_type_id,

    if (!$allowed) {
      $this->expectException(EntityStorageException::class);
      $this->expectExceptionMessage('This entity can only be saved in the default workspace.');
      $this->expectExceptionMessage("The \"$entity_type_id\" entity type can only be saved in the default workspace.");
    }
    $entity->save();
  }