ManagerRegistry.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace Doctrine\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. * @template T
  71. * @psalm-param class-string<T> $persistentObject
  72. * @psalm-return ObjectRepository<T>
  73. */
  74. public function getRepository($persistentObject, $persistentManagerName = null);
  75. /**
  76. * Gets the object manager associated with a given class.
  77. *
  78. * @param string $class A persistent object class name.
  79. *
  80. * @return ObjectManager|null
  81. */
  82. public function getManagerForClass($class);
  83. }