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 |
/** * {@inheritdoc} */ protected function getMenu(BlockContextInterface $blockContext) { $settings = $blockContext->getSettings(); $menu = parent::getMenu($blockContext); if (null === $menu || "" === $menu) { $menu = $this->menuBuilder->createCategoryMenu(array('childrenAttributes' => array('class' => $settings['menu_class']), 'attributes' => array('class' => $settings['children_class'])), $settings['current_uri']); } return $menu; }
public function testCreateCategoryMenu() { $menu = $this->getMock('Knp\\Menu\\ItemInterface'); $factory = $this->getMock('Knp\\Menu\\FactoryInterface'); $factory->expects($this->once())->method('createItem')->will($this->returnValue($menu)); $categoryManager = $this->getMock('Sonata\\Component\\Product\\ProductCategoryManagerInterface'); $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface'); $categoryManager->expects($this->once())->method('getCategoryTree')->will($this->returnValue(array())); $builder = new ProductMenuBuilder($factory, $categoryManager, $router); $genMenu = $builder->createCategoryMenu(); $this->assertInstanceOf('Knp\\Menu\\ItemInterface', $genMenu); }