/** * {@inheritdoc} */ protected function getMenu(BlockContextInterface $blockContext) { $settings = $blockContext->getSettings(); $menu = parent::getMenu($blockContext); if (null === $menu || "" === $menu) { $menu = $this->menuBuilder->createProfileMenu(array('childrenAttributes' => array('class' => $settings['menu_class']), 'attributes' => array('class' => $settings['children_class']))); $menu->setCurrentUri($settings['current_uri']); } return $menu; }
/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $user = false; if ($this->securityContext->getToken()) { $user = $this->securityContext->getToken()->getUser(); } if (!$user instanceof UserInterface) { $user = false; } return $this->renderPrivateResponse($blockContext->getTemplate(), array('user' => $user, 'block' => $blockContext->getBlock(), 'context' => $blockContext)); }
public function testCreateProfileMenu() { $menu = $this->getMock('Knp\\Menu\\ItemInterface'); $factory = $this->getMock('Knp\\Menu\\FactoryInterface'); $factory->expects($this->once())->method('createItem')->will($this->returnValue($menu)); $translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface'); $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $builder = new ProfileMenuBuilder($factory, $translator, array(), $eventDispatcher); $genMenu = $builder->createProfileMenu(); $this->assertInstanceOf('Knp\\Menu\\ItemInterface', $genMenu); }
/** * {@inheritdoc} */ protected function getMenu(BlockContextInterface $blockContext) { $menu = parent::getMenu($blockContext); $settings = $blockContext->getSettings(); if (null === $menu || "" === $menu) { $menu = $this->menuBuilder->createProfileMenu(array('childrenAttributes' => array('class' => $settings['menu_class']), 'attributes' => array('class' => $settings['children_class']))); // Prevents BC break with KnpMenuBundle v1.x if (method_exists($menu, "setCurrentUri")) { $menu->setCurrentUri($settings['current_uri']); } } return $menu; }