I have eventlistener preUpdate
public function preUpdate(PreUpdateEventArgs $args) {
$user = $args->getEntity();
if($user instanceof \iTracker\UserBundle\Entity\User) {
if($args->hasChangedField('userGroup')) {
$old = $args->getOldValue('userGroup');
$new = $args->getNewValue('userGroup');
$em = $args->getEntityManager();
$old->setAmount($old->getAmount() - 1);
$em->persist($old);
$new->setAmount($new->getAmount() + 1);
$em->persist($new);
$em->flush();
}
}
}
And after submiting form i get FatalErrorException: Error: Maximum function nesting level of '100' reached, aborting! in /var/www/issue/app/cache/dev/classes.php line 6123
in /var/www/issue/app/cache/dev/classes.php line 6123 at ErrorHandler->handleFatal() in /var/www/issue/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php line 0 at NormalizerFormatter->normalize() in /var/www/issue/app/cache/dev/classes.php line 6198 at LineFormatter->normalize() in /var/www/issue/app/cache/dev/classes.php line 6112 at NormalizerFormatter->format() in /var/www/issue/app/cache/dev/classes.php line 6172 at LineFormatter->format() in /var/www/issue/app/cache/dev/classes.php line 6320 at AbstractProcessingHandler->handle() in /var/www/issue/app/cache/dev/classes.php line 6646 at Logger->addRecord() in /var/www/issue/app/cache/dev/classes.php line 6710 at Logger->debug() in /var/www/issue/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php line 72 at DbalLogger->log() in /var/www/issue/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php line 50 at DbalLogger->startQuery() in /var/www/issue/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php line 50 at LoggerChain->startQuery() in /var/www/issue/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 774 at Connection->executeUpdate() in /var/www/issue/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 447 at BasicEntityPersister->_updateTable() in /var/www/issue/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 357 at BasicEntityPersister->update() in /var/www/issue/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 984 at UnitOfWork->executeUpdates() in /var/www/issue/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 317 at UnitOfWork->commit() in /var/www/issue/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 355 at EntityManager->flush() in /var/www/issue/src/iTracker/UserBundle/Listener/UserGroupAmount.php line 41 and this
- at UserGroupAmount->preUpdate() in /var/www/issue/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 61
- at ContainerAwareEventManager->dispatchEvent() in /var/www/issue/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 980
- at UnitOfWork->executeUpdates() in /var/www/issue/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 317
- at UnitOfWork->commit() in /var/www/issue/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 355
- at EntityManager->flush() in /var/www/issue/src/iTracker/UserBundle/Listener/UserGroupAmount.php line 41
and this 5 errors are looped, which cause this exception