partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 76a08d2d4b86ae16649ee8267f95426854f957ac
parent baabec0a9cca9da628e295784157b261471ae0e0
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed,  7 Oct 2015 17:22:46 +0200

Also listen for insertions when updating the category path

Diffstat:
Msrc/PartKeepr/FootprintBundle/Listeners/CategoryPathListener.php | 10++++++++--
Msrc/PartKeepr/PartBundle/Listeners/CategoryPathListener.php | 10++++++++--
Msrc/PartKeepr/StorageLocationBundle/Listeners/CategoryPathListener.php | 10++++++++--
3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/PartKeepr/FootprintBundle/Listeners/CategoryPathListener.php b/src/PartKeepr/FootprintBundle/Listeners/CategoryPathListener.php @@ -18,6 +18,12 @@ class CategoryPathListener extends ContainerAware $entityManager = $eventArgs->getEntityManager(); $uow = $entityManager->getUnitOfWork(); + foreach ($uow->getScheduledEntityInsertions() as $updated) { + if ($updated instanceof FootprintCategory) { + $this->updateCategoryPaths($updated, $eventArgs); + } + } + foreach ($uow->getScheduledEntityUpdates() as $updated) { if ($updated instanceof FootprintCategory) { $this->updateCategoryPaths($updated, $eventArgs); @@ -28,8 +34,8 @@ class CategoryPathListener extends ContainerAware /** * Recursively updates the category paths. * - * @param FootprintCategory $footprintCategory The footprint category to update - * @param EntityManager $entityManager The entity manager + * @param FootprintCategory $footprintCategory The footprint category to update + * @param EntityManager $entityManager The entity manager */ public function updateCategoryPaths(FootprintCategory $footprintCategory, OnFlushEventArgs $eventArgs) { diff --git a/src/PartKeepr/PartBundle/Listeners/CategoryPathListener.php b/src/PartKeepr/PartBundle/Listeners/CategoryPathListener.php @@ -18,6 +18,12 @@ class CategoryPathListener extends ContainerAware $entityManager = $eventArgs->getEntityManager(); $uow = $entityManager->getUnitOfWork(); + foreach ($uow->getScheduledEntityInsertions() as $updated) { + if ($updated instanceof PartCategory) { + $this->updateCategoryPaths($updated, $eventArgs); + } + } + foreach ($uow->getScheduledEntityUpdates() as $updated) { if ($updated instanceof PartCategory) { $this->updateCategoryPaths($updated, $eventArgs); @@ -28,8 +34,8 @@ class CategoryPathListener extends ContainerAware /** * Recursively updates the category paths. * - * @param FootprintCategory $partCategory The footprint category to update - * @param EntityManager $entityManager The entity manager + * @param PartCategory $partCategory The footprint category to update + * @param EntityManager $entityManager The entity manager */ public function updateCategoryPaths(PartCategory $partCategory, OnFlushEventArgs $eventArgs) { diff --git a/src/PartKeepr/StorageLocationBundle/Listeners/CategoryPathListener.php b/src/PartKeepr/StorageLocationBundle/Listeners/CategoryPathListener.php @@ -18,6 +18,12 @@ class CategoryPathListener extends ContainerAware $entityManager = $eventArgs->getEntityManager(); $uow = $entityManager->getUnitOfWork(); + foreach ($uow->getScheduledEntityInsertions() as $updated) { + if ($updated instanceof StorageLocationCategory) { + $this->updateCategoryPaths($updated, $eventArgs); + } + } + foreach ($uow->getScheduledEntityUpdates() as $updated) { if ($updated instanceof StorageLocationCategory) { $this->updateCategoryPaths($updated, $eventArgs); @@ -28,8 +34,8 @@ class CategoryPathListener extends ContainerAware /** * Recursively updates the category paths. * - * @param StorageLocationCategory $storageLocationCategory The storage location category to update - * @param EntityManager $entityManager The entity manager + * @param StorageLocationCategory $storageLocationCategory The storage location category to update + * @param EntityManager $entityManager The entity manager */ public function updateCategoryPaths(StorageLocationCategory $storageLocationCategory, OnFlushEventArgs $eventArgs) {