diff options
Diffstat (limited to 'vendor/doctrine/orm/src/EntityNotFoundException.php')
| -rw-r--r-- | vendor/doctrine/orm/src/EntityNotFoundException.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/EntityNotFoundException.php b/vendor/doctrine/orm/src/EntityNotFoundException.php new file mode 100644 index 0000000..142dc8a --- /dev/null +++ b/vendor/doctrine/orm/src/EntityNotFoundException.php | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\ORM; | ||
| 6 | |||
| 7 | use Doctrine\ORM\Exception\ORMException; | ||
| 8 | use RuntimeException; | ||
| 9 | |||
| 10 | use function implode; | ||
| 11 | use function sprintf; | ||
| 12 | |||
| 13 | /** | ||
| 14 | * Exception thrown when a Proxy fails to retrieve an Entity result. | ||
| 15 | */ | ||
| 16 | class EntityNotFoundException extends RuntimeException implements ORMException | ||
| 17 | { | ||
| 18 | /** | ||
| 19 | * Static constructor. | ||
| 20 | * | ||
| 21 | * @param string[] $id | ||
| 22 | */ | ||
| 23 | public static function fromClassNameAndIdentifier(string $className, array $id): self | ||
| 24 | { | ||
| 25 | $ids = []; | ||
| 26 | |||
| 27 | foreach ($id as $key => $value) { | ||
| 28 | $ids[] = $key . '(' . $value . ')'; | ||
| 29 | } | ||
| 30 | |||
| 31 | return new self( | ||
| 32 | 'Entity of type \'' . $className . '\'' . ($ids ? ' for IDs ' . implode(', ', $ids) : '') . ' was not found', | ||
| 33 | ); | ||
| 34 | } | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Instance for which no identifier can be found | ||
| 38 | */ | ||
| 39 | public static function noIdentifierFound(string $className): self | ||
| 40 | { | ||
| 41 | return new self(sprintf( | ||
| 42 | 'Unable to find "%s" entity identifier associated with the UnitOfWork', | ||
| 43 | $className, | ||
| 44 | )); | ||
| 45 | } | ||
| 46 | } | ||
