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

merge-requests/6290/merge
catch 2024-12-09 14:49:15 +00:00
parent 57061f4d39
commit 2b63c15d87
3 changed files with 4 additions and 4 deletions

View File

@ -130,7 +130,7 @@ class EntityOperations implements ContainerInjectionInterface {
// 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 */

View File

@ -172,7 +172,7 @@ class WorkspaceInformationTest extends KernelTestBase {
// 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();
}

View File

@ -690,7 +690,7 @@ class WorkspaceIntegrationTest extends KernelTestBase {
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 @@ class WorkspaceIntegrationTest extends KernelTestBase {
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();
}