public function renderFull() { $bundles = $this->kernel->getBundles(); $return = ''; foreach ($bundles as $bundle) { $bundlePath = $bundle->getPath(); $bundleNamespace = $bundle->getNamespace(); $bundleAlias = $bundle->getName(); if (file_exists($bundlePath . '/Menu/Builder.php')) { $classFullName = $bundleNamespace . '\\' . $this->className; if (method_exists($classFullName, $this->methodName)) { $return .= $this->helper->render($bundleAlias . ':Builder:' . $this->methodName, array('firstClass' => 'teste_primeira_classe', 'currentClass' => 'active')); } } } return $return; }
/** * Renders a bootstrap conform page tree menu * * @param ItemInterface $menu * @param array $options * * @return string */ public function renderBootstrap($menu, array $options = []) { // Set default values $options = array_merge(["template" => "@BecklynPageTree/Menu/bootstrap.html.twig", "currentClass" => "active", "ancestorClass" => "active", "hoverDropdown" => true, "listClass" => "navbar-nav"], $options); // force twig renderer, because we only provide a twig template $helper = new Helper($this->rendererProvider, $this->menuProvider); return $helper->render($menu, $options, "twig"); }
/** * Renders a menu with the specified renderer. * * @param \Knp\Menu\ItemInterface|string|array $menu * @param array $options * @param string $renderer * * @return string */ public function render($menu, array $options = [], $renderer = null) { if (null === $renderer) { $renderer = $menu; } $options['menu'] = $menu; return $this->helper->render($menu, $options, $renderer); }
/** * @param Menu $menu * @param array $options * @return string */ public function prepareMenu(Menu $menu = null, array $options = []) { $html = ''; if ($menu) { $this->prepareItems($menu, $options); $html = $this->helper->render($menu, $options); } return $html; }
/** * Renders the Menu with the specified renderer. * * @param \Knp\Menu\ItemInterface|string|array $menu * @param array $options * @param string $renderer * * @throws \InvalidArgumentException * @return string */ public function renderMenu($menu, array $options = array(), $renderer = null) { $options = array_merge(array('template' => $this->menuTemplate, 'currentClass' => 'active', 'ancestorClass' => 'active', 'allow_safe_labels' => true), $options); if (!$menu instanceof ItemInterface) { $path = array(); if (is_array($menu)) { if (empty($menu)) { throw new \InvalidArgumentException('The array cannot be empty'); } $path = $menu; $menu = array_shift($path); } $menu = $this->helper->get($menu, $path); } $menu = $this->helper->get($menu, array(), $options); if (isset($options['automenu'])) { $this->getMenuConverter()->convert($menu, $options); } return $this->helper->render($menu, $options, $renderer); }
/** * Renders a menu with the specified renderer. * * @param ItemInterface|string|array $menu * @param array $options * @param string $renderer * * @throws \InvalidArgumentException * @return string */ public function render($menu, array $options = array(), $renderer = null) { if (!$menu instanceof ItemInterface) { $path = array(); if (is_array($menu)) { if (empty($menu)) { throw new \InvalidArgumentException('The array cannot be empty'); } $path = $menu; $menu = array_shift($path); } $menu = $this->getMenu($menu, $path, $options); } $menu = $this->filterUnallowedItems($menu); $menuType = $menu->getExtra('type'); // rewrite config options with args if (!empty($menuType) && !empty($this->menuConfiguration['templates'][$menuType])) { $options = array_replace_recursive($this->menuConfiguration['templates'][$menuType], $options); } return $this->helper->render($menu, $options, $renderer); }
/** * Renders a menu with the specified renderer. * * @param ItemInterface|string|array $menu * @param array $options * @param string $renderer * * @throws \InvalidArgumentException * @return string */ public function render($menu, array $options = array(), $renderer = null) { if (!$menu instanceof ItemInterface) { $path = array(); if (is_array($menu)) { if (empty($menu)) { throw new \InvalidArgumentException('The array cannot be empty'); } $path = $menu; $menu = array_shift($path); } $menu = $this->getMenu($menu, $path, $options); } $menuType = $menu->getExtra('type'); if (!empty($menuType)) { $menuConfig = $this->container->getParameter('oro_menu_config'); if (!empty($menuConfig['templates'][$menuType])) { // rewrite config options with args $options = array_replace_recursive($menuConfig['templates'][$menuType], $options); } } return $this->helper->render($menu, $options, $renderer); }
/** * @expectedException InvalidArgumentException * @expectedExceptionMessage The array cannot be empty */ public function testRenderByEmptyPath() { $helper = new Helper($this->getMock('Knp\\Menu\\Renderer\\RendererProviderInterface')); $helper->render(array()); }