public function createRenderer() { $renderer = new ListRenderer(); $renderer->setRenderCompressed(true); return $renderer; }
/** * @return string html */ public function render() { if ($this->getMenu() instanceof ItemInterface === false) { throw new \InvalidArgumentException('Menu needs to conform to the ItemInterface (Knp\\Menu\\ItemInterface)'); } $matcher = new Matcher(); $matcher->addVoter(new UriVoter((string) $this->getBag()->get('url')->getPath())); $renderer = new ListRenderer($matcher); return $renderer->render($this->getMenu()); }
public function testPrettyRendering() { $menu = new MenuItem('Root li', new MenuFactory()); $menu->setChildrenAttributes(array('class' => 'root')); $menu->addChild('Parent 1'); $menu->addChild('Parent 2'); $renderer = new ListRenderer(); $rendered = <<<HTML <ul class="root"> <li class="first"> <span>Parent 1</span> </li> <li class="last"> <span>Parent 2</span> </li> </ul> HTML; $this->assertEquals($rendered, $renderer->render($menu)); }
/** * Constructor. * * @param ContainerInterface $container * @param FactoryInterface $factory */ public function __construct(ContainerInterface $container, FactoryInterface $factory) { $this->container = $container; $this->factory = $factory; $matcher = new Matcher(); try { $request = $this->container->get('request_stack')->getCurrentRequest(); $voter = new RouteVoter($request); $matcher->addVoter($voter); } catch (InactiveScopeException $e) { // We are most probably running from the command line, which means there is no 'request' service. // We just gracefully continue } parent::__construct($matcher, array('allow_safe_labels' => true, 'currentClass' => 'active')); }
/** * @DI\InjectParams({ * "matcher" = @DI\Inject("knp_menu.matcher"), * "defaultOptions" = @DI\Inject("%knp_menu.renderer.list.options%"), * "charset" = @DI\Inject("%kernel.charset%") * }) */ public function __construct($matcher, $defaultOptions, $charset) { $defaultOptions['leaf_class'] = $defaultOptions["branch_class"] = "btn btn-default user-additional-action"; parent::__construct($matcher, $defaultOptions, $charset); }
/** * @DI\InjectParams({ * "matcher" = @DI\Inject("knp_menu.matcher"), * "defaultOptions" = @DI\Inject("%knp_menu.renderer.list.options%"), * "charset" = @DI\Inject("%kernel.charset%") * }) */ public function __construct($matcher, $defaultOptions, $charset) { $defaultOptions['leaf_class'] = $defaultOptions["branch_class"] = "list-group-item"; parent::__construct($matcher, $defaultOptions, $charset); }
/** * Renders the current controller template * @param string $name * @param array $elements * @return mixed */ public function renderTemplate($name, $elements = array()) { $name = $this->getTemplatePath() . '/' . $name; $renderer = new ListRenderer(new \Knp\Menu\Matcher\Matcher()); $action = $this->getRequest()->get('_route'); $result = $renderer->render($this->getBreadcrumbs($action)); $elements['new_breadcrumb'] = $result; return $this->getTemplate()->renderTemplate($name, $elements); }
/** * @DI\InjectParams({ * "matcher" = @DI\Inject("knp_menu.matcher"), * "defaultOptions" = @DI\Inject("%knp_menu.renderer.list.options%"), * "charset" = @DI\Inject("%kernel.charset%") * }) */ public function __construct($matcher, $defaultOptions, $charset) { parent::__construct($matcher, $defaultOptions, $charset); }
/** * @DI\InjectParams({ * "matcher" = @DI\Inject("knp_menu.matcher"), * "defaultOptions" = @DI\Inject("%knp_menu.renderer.list.options%"), * "charset" = @DI\Inject("%kernel.charset%") * }) */ public function __construct($matcher, $defaultOptions, $charset) { $defaultOptions['leaf_class'] = $defaultOptions['branch_class'] = 'btn btn-default workspace-additional-action'; parent::__construct($matcher, $defaultOptions, $charset); }
/** * Get HTML Links in list form * * @param string $markup Content to get items from * @param int $topLevel Top Header (1 through 6) * @param int $depth Depth (1 through 6) * @param RendererInterface $renderer * @return string HTML <LI> items */ public function getHtmlMenu($markup, $topLevel = 1, $depth = 6, RendererInterface $renderer = null) { if (!$renderer) { $renderer = new ListRenderer(new Matcher(), ['currentClass' => 'active', 'ancestorClass' => 'active_ancestor']); } return $renderer->render($this->getMenu($markup, $topLevel, $depth)); }
/** * @param ItemInterface $item * @param array $options * * @return string */ public function render(ItemInterface $item, array $options = []) { $this->renderRootElement($item, $options); return parent::render($item, $options); }
public function __construct(MatcherInterface $matcher, MenuManipulator $manipulator, array $defaultOptions = array(), $charset = null) { parent::__construct($matcher, $defaultOptions, $charset); $this->manipulator = $manipulator; }
/** * {@inheritdoc} */ public function render(ItemInterface $item, array $options = array()) { $options = array_merge(array('currentClass' => 'current active', 'ancestorClass' => 'current_ancestor active', 'allow_safe_labels' => true), $options); return parent::render($item, $options); }