PHP Class Elcodi\Admin\ProductBundle\Services\CategorySorter

Show file Open project: elcodi/bamboo

Public Methods

Method Description
__construct ( Elcodi\Component\Product\Repository\CategoryRepository $categoryRepository, Doctrine\Common\Persistence\ObjectManager $categoryObjectManager, Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher ) Builds a new category order service.
sort ( array $categoriesOrder ) : boolean Sort the received categories based on the received order.

Protected Methods

Method Description
sortCategoriesTree ( array $categoriesOrder, Elcodi\Component\Product\Entity\Category | null $parentCategory = null ) : boolean Sort a category tree based on the received order recursively.

Method Details

__construct() public method

Builds a new category order service.
public __construct ( Elcodi\Component\Product\Repository\CategoryRepository $categoryRepository, Doctrine\Common\Persistence\ObjectManager $categoryObjectManager, Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher )
$categoryRepository Elcodi\Component\Product\Repository\CategoryRepository The category repository
$categoryObjectManager Doctrine\Common\Persistence\ObjectManager The category object manager
$eventDispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface An event dispatcher instance

sort() public method

The order is received on the following format: [ [ 'id' => xx, 'subtree' => [ 'id' => xx, 'subtree' => [] ] ], [ 'id' => xx, 'subtree' => [ [ 'id' => xx, 'subtree' => [ 'id' => xx, 'subtree' => [] ] ] ] ], ]
public sort ( array $categoriesOrder ) : boolean
$categoriesOrder array The category order (See function comment)
return boolean If the order process has finished right.

sortCategoriesTree() protected method

Sort a category tree based on the received order recursively.
protected sortCategoriesTree ( array $categoriesOrder, Elcodi\Component\Product\Entity\Category | null $parentCategory = null ) : boolean
$categoriesOrder array The category order
$parentCategory Elcodi\Component\Product\Entity\Category | null The parent category in case is not a root category.
return boolean If the order process has finished right.