ManagerRegistry.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace Doctrine\Common\Persistence;
  3. /**
  4. * Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement.
  5. */
  6. interface ManagerRegistry extends ConnectionRegistry
  7. {
  8. /**
  9. * Gets the default object manager name.
  10. *
  11. * @return string The default object manager name.
  12. */
  13. public function getDefaultManagerName();
  14. /**
  15. * Gets a named object manager.
  16. *
  17. * @param string $name The object manager name (null for the default one).
  18. *
  19. * @return ObjectManager
  20. */
  21. public function getManager($name = null);
  22. /**
  23. * Gets an array of all registered object managers.
  24. *
  25. * @return ObjectManager[] An array of ObjectManager instances
  26. */
  27. public function getManagers();
  28. /**
  29. * Resets a named object manager.
  30. *
  31. * This method is useful when an object manager has been closed
  32. * because of a rollbacked transaction AND when you think that
  33. * it makes sense to get a new one to replace the closed one.
  34. *
  35. * Be warned that you will get a brand new object manager as
  36. * the existing one is not useable anymore. This means that any
  37. * other object with a dependency on this object manager will
  38. * hold an obsolete reference. You can inject the registry instead
  39. * to avoid this problem.
  40. *
  41. * @param string|null $name The object manager name (null for the default one).
  42. *
  43. * @return ObjectManager
  44. */
  45. public function resetManager($name = null);
  46. /**
  47. * Resolves a registered namespace alias to the full namespace.
  48. *
  49. * This method looks for the alias in all registered object managers.
  50. *
  51. * @param string $alias The alias.
  52. *
  53. * @return string The full namespace.
  54. */
  55. public function getAliasNamespace($alias);
  56. /**
  57. * Gets all object manager names.
  58. *
  59. * @return string[] An array of object manager names.
  60. */
  61. public function getManagerNames();
  62. /**
  63. * Gets the ObjectRepository for a persistent object.
  64. *
  65. * @param string $persistentObject The name of the persistent object.
  66. * @param string $persistentManagerName The object manager name (null for the default one).
  67. *
  68. * @return ObjectRepository
  69. */
  70. public function getRepository($persistentObject, $persistentManagerName = null);
  71. /**
  72. * Gets the object manager associated with a given class.
  73. *
  74. * @param string $class A persistent object class name.
  75. *
  76. * @return ObjectManager|null
  77. */
  78. public function getManagerForClass($class);
  79. }