I use doctrine events (listener and subscriber ), in both of them i have such a problem : when i run postPersist they do not run all the time. I mean in a foreach i call doctrine remove but the event only call once and not more? can some one give me some directions?
Sample code is below:
foreach ($input as $key => $value) {
$entity = $this
->findOneBy([$this->primaryKeyName => $value[$this->primaryKeyName]]);
if($i!=1)
$this->_em->getEventManager()->dispatchEvent('postUpdate',new LifecycleEventArgs($entity,$this->_em));
$i++;
$this->_em->remove($entity);
$this->_em->flush();
$result[] = $value;
}
retu $result;
