ObjectRepository.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Doctrine\Common\Persistence;
  3. use UnexpectedValueException;
  4. /**
  5. * Contract for a Doctrine persistence layer ObjectRepository class to implement.
  6. */
  7. interface ObjectRepository
  8. {
  9. /**
  10. * Finds an object by its primary key / identifier.
  11. *
  12. * @param mixed $id The identifier.
  13. *
  14. * @return object|null The object.
  15. */
  16. public function find($id);
  17. /**
  18. * Finds all objects in the repository.
  19. *
  20. * @return object[] The objects.
  21. */
  22. public function findAll();
  23. /**
  24. * Finds objects by a set of criteria.
  25. *
  26. * Optionally sorting and limiting details can be passed. An implementation may throw
  27. * an UnexpectedValueException if certain values of the sorting or limiting details are
  28. * not supported.
  29. *
  30. * @param mixed[] $criteria
  31. * @param string[]|null $orderBy
  32. * @param int|null $limit
  33. * @param int|null $offset
  34. *
  35. * @return object[] The objects.
  36. *
  37. * @throws UnexpectedValueException
  38. */
  39. public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null);
  40. /**
  41. * Finds a single object by a set of criteria.
  42. *
  43. * @param mixed[] $criteria The criteria.
  44. *
  45. * @return object|null The object.
  46. */
  47. public function findOneBy(array $criteria);
  48. /**
  49. * Returns the class name of the object managed by the repository.
  50. *
  51. * @return string
  52. */
  53. public function getClassName();
  54. }