ManagerRegistry.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the MIT license. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\Common\Persistence;
  20. /**
  21. * Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement.
  22. *
  23. * @link www.doctrine-project.org
  24. * @since 2.2
  25. * @author Fabien Potencier <fabien@symfony.com>
  26. * @author Benjamin Eberlei <kontakt@beberlei.de>
  27. * @author Lukas Kahwe Smith <smith@pooteeweet.org>
  28. */
  29. interface ManagerRegistry extends ConnectionRegistry
  30. {
  31. /**
  32. * Gets the default object manager name.
  33. *
  34. * @return string The default object manager name.
  35. */
  36. public function getDefaultManagerName();
  37. /**
  38. * Gets a named object manager.
  39. *
  40. * @param string $name The object manager name (null for the default one).
  41. *
  42. * @return \Doctrine\Common\Persistence\ObjectManager
  43. */
  44. public function getManager($name = null);
  45. /**
  46. * Gets an array of all registered object managers.
  47. *
  48. * @return \Doctrine\Common\Persistence\ObjectManager[] An array of ObjectManager instances
  49. */
  50. public function getManagers();
  51. /**
  52. * Resets a named object manager.
  53. *
  54. * This method is useful when an object manager has been closed
  55. * because of a rollbacked transaction AND when you think that
  56. * it makes sense to get a new one to replace the closed one.
  57. *
  58. * Be warned that you will get a brand new object manager as
  59. * the existing one is not useable anymore. This means that any
  60. * other object with a dependency on this object manager will
  61. * hold an obsolete reference. You can inject the registry instead
  62. * to avoid this problem.
  63. *
  64. * @param string|null $name The object manager name (null for the default one).
  65. *
  66. * @return \Doctrine\Common\Persistence\ObjectManager
  67. */
  68. public function resetManager($name = null);
  69. /**
  70. * Resolves a registered namespace alias to the full namespace.
  71. *
  72. * This method looks for the alias in all registered object managers.
  73. *
  74. * @param string $alias The alias.
  75. *
  76. * @return string The full namespace.
  77. */
  78. public function getAliasNamespace($alias);
  79. /**
  80. * Gets all connection names.
  81. *
  82. * @return array An array of connection names.
  83. */
  84. public function getManagerNames();
  85. /**
  86. * Gets the ObjectRepository for an persistent object.
  87. *
  88. * @param string $persistentObject The name of the persistent object.
  89. * @param string $persistentManagerName The object manager name (null for the default one).
  90. *
  91. * @return \Doctrine\Common\Persistence\ObjectRepository
  92. */
  93. public function getRepository($persistentObject, $persistentManagerName = null);
  94. /**
  95. * Gets the object manager associated with a given class.
  96. *
  97. * @param string $class A persistent object class name.
  98. *
  99. * @return \Doctrine\Common\Persistence\ObjectManager|null
  100. */
  101. public function getManagerForClass($class);
  102. }