ManagerRegistry.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 LGPL. 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. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  24. * @link www.doctrine-project.org
  25. * @since 2.2
  26. * @author Fabien Potencier <fabien@symfony.com>
  27. * @author Benjamin Eberlei <kontakt@beberlei.de>
  28. * @author Lukas Kahwe Smith <smith@pooteeweet.org>
  29. */
  30. interface ManagerRegistry extends ConnectionRegistry
  31. {
  32. /**
  33. * Gets the default object manager name.
  34. *
  35. * @return string The default object manager name
  36. */
  37. function getDefaultManagerName();
  38. /**
  39. * Gets a named object manager.
  40. *
  41. * @param string $name The object manager name (null for the default one)
  42. *
  43. * @return \Doctrine\Common\Persistence\ObjectManager
  44. */
  45. function getManager($name = null);
  46. /**
  47. * Gets an array of all registered object managers
  48. *
  49. * @return array An array of ObjectManager instances
  50. */
  51. function getManagers();
  52. /**
  53. * Resets a named object manager.
  54. *
  55. * This method is useful when an object manager has been closed
  56. * because of a rollbacked transaction AND when you think that
  57. * it makes sense to get a new one to replace the closed one.
  58. *
  59. * Be warned that you will get a brand new object manager as
  60. * the existing one is not useable anymore. This means that any
  61. * other object with a dependency on this object manager will
  62. * hold an obsolete reference. You can inject the registry instead
  63. * to avoid this problem.
  64. *
  65. * @param string $name The object manager name (null for the default one)
  66. *
  67. * @return \Doctrine\Common\Persistence\ObjectManager
  68. */
  69. function resetManager($name = null);
  70. /**
  71. * Resolves a registered namespace alias to the full namespace.
  72. *
  73. * This method looks for the alias in all registered object managers.
  74. *
  75. * @param string $alias The alias
  76. *
  77. * @return string The full namespace
  78. */
  79. function getAliasNamespace($alias);
  80. /**
  81. * Gets all connection names.
  82. *
  83. * @return array An array of connection names
  84. */
  85. function getManagerNames();
  86. /**
  87. * Gets the ObjectRepository for an persistent object.
  88. *
  89. * @param string $persistentObject The name of the persistent object.
  90. * @param string $persistentManagerName The object manager name (null for the default one)
  91. *
  92. * @return \Doctrine\Common\Persistence\ObjectRepository
  93. */
  94. function getRepository($persistentObject, $persistentManagerName = null);
  95. /**
  96. * Gets the object manager associated with a given class.
  97. *
  98. * @param string $class A persistent object class name
  99. *
  100. * @return \Doctrine\Common\Persistence\ObjectManager|null
  101. */
  102. function getManagerForClass($class);
  103. }