From af455891561f49e1d51a9b107ac2349efb81cb7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Karlovi=C4=87?= Date: Wed, 17 Oct 2018 11:44:10 +0200 Subject: [PATCH] Managers WIP --- .../ObjectManagerRegistryPersister.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/Bridge/Doctrine/Persister/ObjectManagerRegistryPersister.php diff --git a/src/Bridge/Doctrine/Persister/ObjectManagerRegistryPersister.php b/src/Bridge/Doctrine/Persister/ObjectManagerRegistryPersister.php new file mode 100644 index 00000000..9ce11ef2 --- /dev/null +++ b/src/Bridge/Doctrine/Persister/ObjectManagerRegistryPersister.php @@ -0,0 +1,63 @@ +managerRegistries = $managerRegistries; + } + + /** + * Persists objects into the database. + * + * @param object $object + */ + public function persist($object) + { + foreach ($this->getManagerPersisters() as $persister) { + $persister->persist($object); + } + } + + public function flush() + { + foreach ($this->getManagerPersisters() as $persister) { + $persister->flush(); + } + } + + private function getManagerPersisters() + { + if (null === $this->managerPersisters) { + $this->managerPersisters = []; + + foreach ($this->managerRegistries as $managerRegistry) { + foreach ($managerRegistry->getManagers() as $manager) { + $this->managerPersisters[] = new ObjectManagerPersister($manager); + } + } + } + + return $this->managerPersisters; + } +}