vendor/doctrine/orm/src/EntityNotFoundException.php line 15

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\ORM;
  4. use Doctrine\ORM\Exception\ORMException;
  5. use function implode;
  6. use function sprintf;
  7. /**
  8. * Exception thrown when a Proxy fails to retrieve an Entity result.
  9. */
  10. class EntityNotFoundException extends ORMException
  11. {
  12. /**
  13. * Static constructor.
  14. *
  15. * @param string $className
  16. * @param string[] $id
  17. *
  18. * @return self
  19. */
  20. public static function fromClassNameAndIdentifier($className, array $id)
  21. {
  22. $ids = [];
  23. foreach ($id as $key => $value) {
  24. $ids[] = $key . '(' . $value . ')';
  25. }
  26. return new self(
  27. 'Entity of type \'' . $className . '\'' . ($ids ? ' for IDs ' . implode(', ', $ids) : '') . ' was not found'
  28. );
  29. }
  30. /**
  31. * Instance for which no identifier can be found
  32. */
  33. public static function noIdentifierFound(string $className): self
  34. {
  35. return new self(sprintf(
  36. 'Unable to find "%s" entity identifier associated with the UnitOfWork',
  37. $className
  38. ));
  39. }
  40. }