RegistryInterface.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Bridge\Doctrine;
  11. use Doctrine\DBAL\Connection;
  12. use Doctrine\ORM\Configuration;
  13. use Doctrine\ORM\ORMException;
  14. /**
  15. * References Doctrine connections and entity managers.
  16. *
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. */
  19. interface RegistryInterface
  20. {
  21. /**
  22. * Gets the default connection name.
  23. *
  24. * @return string The default connection name
  25. */
  26. function getDefaultConnectionName();
  27. /**
  28. * Gets the named connection.
  29. *
  30. * @param string $name The connection name (null for the default one)
  31. *
  32. * @return Connection
  33. */
  34. function getConnection($name = null);
  35. /**
  36. * Gets an array of all registered connections
  37. *
  38. * @return array An array of Connection instances
  39. */
  40. function getConnections();
  41. /**
  42. * Gets all connection names.
  43. *
  44. * @return array An array of connection names
  45. */
  46. function getConnectionNames();
  47. /**
  48. * Gets the default entity manager name.
  49. *
  50. * @return string The default entity manager name
  51. */
  52. function getDefaultEntityManagerName();
  53. /**
  54. * Gets a named entity manager.
  55. *
  56. * @param string $name The entity manager name (null for the default one)
  57. *
  58. * @return EntityManager
  59. */
  60. function getEntityManager($name = null);
  61. /**
  62. * Gets an array of all registered entity managers
  63. *
  64. * @return array An array of EntityManager instances
  65. */
  66. function getEntityManagers();
  67. /**
  68. * Resets a named entity manager.
  69. *
  70. * This method is useful when an entity manager has been closed
  71. * because of a rollbacked transaction AND when you think that
  72. * it makes sense to get a new one to replace the closed one.
  73. *
  74. * Be warned that you will get a brand new entity manager as
  75. * the existing one is not useable anymore. This means that any
  76. * other object with a dependency on this entity manager will
  77. * hold an obsolete reference. You can inject the registry instead
  78. * to avoid this problem.
  79. *
  80. * @param string $name The entity manager name (null for the default one)
  81. *
  82. * @return EntityManager
  83. */
  84. function resetEntityManager($name = null);
  85. /**
  86. * Resolves a registered namespace alias to the full namespace.
  87. *
  88. * This method looks for the alias in all registered entity managers.
  89. *
  90. * @param string $alias The alias
  91. *
  92. * @return string The full namespace
  93. *
  94. * @see Configuration::getEntityNamespace
  95. */
  96. function getEntityNamespace($alias);
  97. /**
  98. * Gets all connection names.
  99. *
  100. * @return array An array of connection names
  101. */
  102. function getEntityManagerNames();
  103. /**
  104. * Gets the EntityRepository for an entity.
  105. *
  106. * @param string $entityName The name of the entity.
  107. * @param string $entityManagerNAme The entity manager name (null for the default one)
  108. *
  109. * @return Doctrine\ORM\EntityRepository
  110. */
  111. function getRepository($entityName, $entityManagerName = null);
  112. /**
  113. * Gets the entity manager associated with a given object.
  114. *
  115. * @param object $object A Doctrine Entity
  116. *
  117. * @return EntityManager|null
  118. */
  119. function getEntityManagerForObject($object);
  120. }