diff --git a/src/Bridge/Doctrine/Persister/ObjectManagerPersister.php b/src/Bridge/Doctrine/Persister/ObjectManagerPersister.php index 2c52f5dd..70a87dfe 100644 --- a/src/Bridge/Doctrine/Persister/ObjectManagerPersister.php +++ b/src/Bridge/Doctrine/Persister/ObjectManagerPersister.php @@ -32,14 +32,13 @@ private $objectManager; /** - * @var array Values are FQCN of persistable objects + * @var array|null Values are FQCN of persistable objects */ private $persistableClasses; public function __construct(ObjectManager $manager) { $this->objectManager = $manager; - $this->persistableClasses = array_flip($this->getPersistableClasses($manager)); } /** @@ -47,6 +46,10 @@ public function __construct(ObjectManager $manager) */ public function persist($object) { + if (null === $this->persistableClasses) { + $this->persistableClasses = array_flip($this->getPersistableClasses($this->objectManager)); + } + if (isset($this->persistableClasses[get_class($object)])) { $this->objectManager->persist($object); }