コード例 #1
0
ファイル: Navigation.php プロジェクト: mizzencms/core
 /**
  * @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());
 }
コード例 #2
0
    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));
    }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
ファイル: TocGenerator.php プロジェクト: caseyamcl/toc
 /**
  * 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));
 }
コード例 #5
0
ファイル: VainPresenter.php プロジェクト: vainproject/vain
 /**
  * @param ItemInterface $item
  * @param array         $options
  *
  * @return string
  */
 public function render(ItemInterface $item, array $options = [])
 {
     $this->renderRootElement($item, $options);
     return parent::render($item, $options);
 }
コード例 #6
0
 /**
  * {@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);
 }