Skip to content

Commit a434173

Browse files
lyrixxsoyuka
andauthoredMar 7, 2025
fix(doctrine): Add a proper exception when a doctrine manager could not be found for a resource class (#6995)
* fix(doctrine): Add a proper exception when a doctrine manager could not be found for a resource class * Update ItemProvider.php --------- Co-authored-by: Antoine Bluchet <soyuka@users.noreply.github.com>
1 parent f5a8d45 commit a434173

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎src/Doctrine/Orm/State/ItemProvider.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
5353
$entityClass = $options->getEntityClass();
5454
}
5555

56-
/** @var EntityManagerInterface $manager */
56+
/** @var EntityManagerInterface|null $manager */
5757
$manager = $this->managerRegistry->getManagerForClass($entityClass);
58+
if (null === $manager) {
59+
throw new RuntimeException(\sprintf('No manager found for class "%s". Are you sure it\'s an entity?', $entityClass));
60+
}
5861

5962
$fetchData = $context['fetch_data'] ?? true;
6063
if (!$fetchData && \array_key_exists('id', $uriVariables)) {

0 commit comments

Comments
 (0)