PHP Class Sonata\ProductBundle\Menu\ProductMenuBuilder

Author: Hugo Briand ([email protected])
Show file Open project: sonata-project/ecommerce Class Usage Examples

Protected Properties

Property Type Description
$categoryManager Sonata\Component\Product\ProductCategoryManagerInterface
$factory Knp\Menu\FactoryInterface
$router Symfony\Component\Routing\RouterInterface

Public Methods

Method Description
__construct ( Knp\Menu\FactoryInterface $factory, Sonata\Component\Product\ProductCategoryManagerInterface $categoryManager, Symfony\Component\Routing\RouterInterface $router ) Constructor.
buildCategoryMenu ( Knp\Menu\ItemInterface $menu, array $options = [], string $currentUri = null )
createCategoryMenu ( array $itemOptions = [], string $currentUri = null ) : Knp\Menu\ItemInterface
createFiltersMenu ( Sonata\Component\Product\ProductProviderInterface $productProvider, array $itemOptions = [], string $currentUri = null ) : mixed Generates the filters menu based on $productProvider.

Protected Methods

Method Description
fillMenu ( Knp\Menu\ItemInterface $menu, array $categories, array $options = [], string $currentUri = null ) Recursive method to fill $menu with $categories.
getCategoryTitle ( Sonata\ClassificationBundle\Model\CategoryInterface $category, integer $limit = 500 ) : string Gets the HTML associated with the category menu title.
getFilterName ( $filter, $option ) : string Generates the name of the filter based on $filter and $option.
getFilterUri ( $currentUri, $filter, $option ) : string Generates the filter uri.

Method Details

__construct() public method

Constructor.
public __construct ( Knp\Menu\FactoryInterface $factory, Sonata\Component\Product\ProductCategoryManagerInterface $categoryManager, Symfony\Component\Routing\RouterInterface $router )
$factory Knp\Menu\FactoryInterface
$categoryManager Sonata\Component\Product\ProductCategoryManagerInterface
$router Symfony\Component\Routing\RouterInterface

buildCategoryMenu() public method

public buildCategoryMenu ( Knp\Menu\ItemInterface $menu, array $options = [], string $currentUri = null )
$menu Knp\Menu\ItemInterface The item to fill with $routes
$options array The item options
$currentUri string The current URI

createCategoryMenu() public method

public createCategoryMenu ( array $itemOptions = [], string $currentUri = null ) : Knp\Menu\ItemInterface
$itemOptions array The options given to the created menuItem
$currentUri string The current URI
return Knp\Menu\ItemInterface

createFiltersMenu() public method

Generates the filters menu based on $productProvider.
public createFiltersMenu ( Sonata\Component\Product\ProductProviderInterface $productProvider, array $itemOptions = [], string $currentUri = null ) : mixed
$productProvider Sonata\Component\Product\ProductProviderInterface
$itemOptions array
$currentUri string
return mixed

fillMenu() protected method

Recursive method to fill $menu with $categories.
protected fillMenu ( Knp\Menu\ItemInterface $menu, array $categories, array $options = [], string $currentUri = null )
$menu Knp\Menu\ItemInterface
$categories array
$options array
$currentUri string

getCategoryTitle() protected method

Gets the HTML associated with the category menu title.
protected getCategoryTitle ( Sonata\ClassificationBundle\Model\CategoryInterface $category, integer $limit = 500 ) : string
$category Sonata\ClassificationBundle\Model\CategoryInterface A category instance
$limit integer A limit for calculation (fixed to 500 by default)
return string

getFilterName() protected method

Generates the name of the filter based on $filter and $option.
protected getFilterName ( $filter, $option ) : string
$filter
$option
return string

getFilterUri() protected method

Generates the filter uri.
protected getFilterUri ( $currentUri, $filter, $option ) : string
$currentUri
$filter
$option
return string

Property Details

$categoryManager protected property

protected ProductCategoryManagerInterface,Sonata\Component\Product $categoryManager
return Sonata\Component\Product\ProductCategoryManagerInterface

$factory protected property

protected FactoryInterface,Knp\Menu $factory
return Knp\Menu\FactoryInterface

$router protected property

protected RouterInterface,Symfony\Component\Routing $router
return Symfony\Component\Routing\RouterInterface