ManagerInterface.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\CoreBundle\Model;
  11. use Doctrine\DBAL\Connection;
  12. /**
  13. * @author Sylvain Deloux <sylvain.deloux@ekino.com>
  14. */
  15. interface ManagerInterface
  16. {
  17. /**
  18. * Return the Entity class name.
  19. *
  20. * @return string
  21. */
  22. public function getClass();
  23. /**
  24. * Find all entities in the repository.
  25. *
  26. * @return array
  27. */
  28. public function findAll();
  29. /**
  30. * Find entities by a set of criteria.
  31. *
  32. * @param array $criteria
  33. * @param array|null $orderBy
  34. * @param int|null $limit
  35. * @param int|null $offset
  36. *
  37. * @return array
  38. */
  39. public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null);
  40. /**
  41. * Find a single entity by a set of criteria.
  42. *
  43. * @param array $criteria
  44. * @param array|null $orderBy
  45. *
  46. * @return object|null
  47. */
  48. public function findOneBy(array $criteria, array $orderBy = null);
  49. /**
  50. * Finds an entity by its primary key / identifier.
  51. *
  52. * @param mixed $id The identifier
  53. *
  54. * @return object
  55. */
  56. public function find($id);
  57. /**
  58. * Create an empty Entity instance.
  59. *
  60. * @return object
  61. */
  62. public function create();
  63. /**
  64. * Save an Entity.
  65. *
  66. * @param object $entity The Entity to save
  67. * @param bool $andFlush Flush the EntityManager after saving the object?
  68. */
  69. public function save($entity, $andFlush = true);
  70. /**
  71. * Delete an Entity.
  72. *
  73. * @param object $entity The Entity to delete
  74. * @param bool $andFlush Flush the EntityManager after deleting the object?
  75. */
  76. public function delete($entity, $andFlush = true);
  77. /**
  78. * Get the related table name.
  79. *
  80. * @return string
  81. */
  82. public function getTableName();
  83. /**
  84. * Get the DB driver connection.
  85. *
  86. * @return Connection
  87. */
  88. public function getConnection();
  89. }