fix creation of new element when a menu is edited
This commit is contained in:
parent
8869175340
commit
9d7f140923
|
@ -66,7 +66,7 @@ class MenuEventSubscriber extends EntityManagerEventSubscriber
|
||||||
|
|
||||||
$menu = $event->getEntity();
|
$menu = $event->getEntity();
|
||||||
|
|
||||||
if (count($menu->getNodes()) > 2) {
|
if (count($menu->getNodes()) >= 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,10 +84,10 @@ class MenuEventSubscriber extends EntityManagerEventSubscriber
|
||||||
|
|
||||||
$menu->setRootNode($rootNode);
|
$menu->setRootNode($rootNode);
|
||||||
|
|
||||||
$this->entityManager->getEntityManager()->persist($rootNode);
|
foreach ([$rootNode, $childNode, $menu] as $entity) {
|
||||||
$this->entityManager->getEntityManager()->persist($childNode);
|
$this->entityManager->getEntityManager()->persist($entity);
|
||||||
|
}
|
||||||
|
|
||||||
$this->entityManager->getEntityManager()->persist($menu);
|
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
$this->nodeRepository->persistAsFirstChild($childNode, $rootNode);
|
$this->nodeRepository->persistAsFirstChild($childNode, $rootNode);
|
||||||
|
|
Loading…
Reference in a new issue