PartKeepr\PartBundle\Listeners\CategoryPathListener::onFlush PHP Method

onFlush() public method

Updates the child category paths when their parent name has changed.
public onFlush ( Doctrine\ORM\Event\OnFlushEventArgs $eventArgs )
$eventArgs Doctrine\ORM\Event\OnFlushEventArgs The event arguments as given by Doctrine
    public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $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);
            }
        }
    }