Closed Brewal closed 5 days ago
I'm using foundry without doctrine and manually save my objects with this function in my factories :
protected function initialize(): self { return $this->withoutPersisting() ->afterInstantiate( fn (Establishment $establishment) => $this->repository->save($establishment), ); }
I'm facing an issue while using stories and pools.
If I call $this->addToPool() inside a story, I get the following error :
$this->addToPool()
RuntimeException : Should not get doctrine's object manager when persist is disabled.
What I understood is that I wouldn't be able to use pools because of the normalizeObject private method of Story :
normalizeObject
Story
// ensure proxies are persisted if (!$object->isPersisted()) { $object->save(); }
Is there a workaround for this use case ?
Thanks to this : https://github.com/zenstruck/foundry/pull/488 we can globally disable persist. Would it make sense to check for this configuration in the Story ?
this is fixed!
I'm using foundry without doctrine and manually save my objects with this function in my factories :
I'm facing an issue while using stories and pools.
If I call
$this->addToPool()
inside a story, I get the following error :What I understood is that I wouldn't be able to use pools because of the
normalizeObject
private method ofStory
:Is there a workaround for this use case ?
Thanks to this : https://github.com/zenstruck/foundry/pull/488 we can globally disable persist. Would it make sense to check for this configuration in the Story ?