public function sortCategories(array $items)
    {
        $repository = $this->getRepository();
        $em         = $this->getDoctrineHelper()->getEntityManager();

        foreach ($items as $item) {
            $parent = $repository->find($item['parent']);
            $child  = $repository->find($item['id']);
            if (null !== $child) {
                $child->setParent($parent);
                $child->setHierarchy($item['weight']);
                $em->persist($child);
            }
        }

        $em->flush();
    }
public function sortCategories(array $items)
    {
        $repository = $this->getRepository();
        $em         = $this->getDoctrineHelper()->getEntityManager();

        foreach ($items as $item) {
            $parent = $repository->find($item['parent']);
            $child  = $repository->find($item['id']);
            if (null !== $child) {
                $child->setParent($parent);
                $child->setHierarchy($item['weight']);
                $em->persist($child);
            }
        }

        $em->flush();
    }
public function sortCategories ( array $ items ) { $ repository = $ this -> getRepository ( ) ; $ em = $ this -> getDoctrineHelper ( ) -> getEntityManager ( ) ; foreach ( $ items as $ item ) { $ parent = $ repository -> find ( $ item [ 'parent' ] ) ; $ child = $ repository -> find ( $ item [ 'id' ] ) ; if ( null !== $ child ) { $ child -> setParent ( $ parent ) ; $ child -> setHierarchy ( $ item [ 'weight' ] ) ; $ em -> persist ( $ child ) ; } } $ em -> flush ( ) ; }
Sorts categories passed in request

@param array $items
Sorts categories passed in request