/**
  * {@inheritdoc}
  */
 public function render(ItemInterface $item, array $options = array())
 {
     $activeItem = $this->getActiveItem($item);
     if (!$activeItem) {
         return '';
     }
     $options = array_merge($this->defaultOptions, $options, array('currentClass' => 'active'));
     $breadcrumbArray = $this->manipulator->getBreadcrumbsArray($activeItem);
     $html = $this->renderList($breadcrumbArray, $options);
     if ($options['clear_matcher']) {
         $this->matcher->clear();
     }
     return $html;
 }
 /**
  * Renders a menu with the specified renderer.
  *
  * @param ItemInterface|string|array $menu
  *
  * @return string
  */
 public function getBreadcrumb($menu, $actions = null)
 {
     $menu = $this->helper->get($menu);
     $treeIterator = new \RecursiveIteratorIterator(new RecursiveItemIterator(new \ArrayIterator(array($menu))), \RecursiveIteratorIterator::SELF_FIRST);
     $iterator = new CurrentItemFilterIterator($treeIterator, $this->matcher);
     $manipulator = new MenuManipulator();
     foreach ($iterator as $item) {
         return $manipulator->getBreadcrumbsArray($item);
     }
 }
 /**
  * Render an array or KNP menu as foundation breadcrumb
  *
  * @param ItemInterface|string $menu
  * @param array $options
  * @return mixed
  */
 public function renderAsBreadcrumb($menu, array $options = array())
 {
     $options = array_merge(array('template' => $this->defaultTemplate), $options);
     if (!is_array($menu) && !$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->menuHelper->get($menu, $path);
     }
     // Look into the menu to fetch the current item
     $treeIterator = new \RecursiveIteratorIterator(new RecursiveItemIterator(new \ArrayIterator(array($menu))), \RecursiveIteratorIterator::SELF_FIRST);
     $itemFilterIterator = new CurrentItemFilterIterator($treeIterator, $this->matcher);
     $itemFilterIterator->rewind();
     // Watch for a current item
     $current = $itemFilterIterator->current();
     $manipulator = new MenuManipulator();
     if ($current instanceof ItemInterface) {
         // Extract the items for the breadcrumb
         $breadcrumbs = $manipulator->getBreadcrumbsArray($current);
     } else {
         // Current item could not be located, we only send the first item
         $breadcrumbs = $manipulator->getBreadcrumbsArray($menu);
     }
     // Load the template if needed
     if (!$options['template'] instanceof \Twig_Template) {
         $options['template'] = $this->twig->loadTemplate($options['template']);
     }
     return $options['template']->renderBlock('root', array('breadcrumbs' => $breadcrumbs, 'options' => $options));
 }
 /**
  * Return breadcrumb array
  *
  * @param $menuName
  * @param $item
  * @param bool $isInverse
  * @return array
  */
 public function getBreadcrumbArray($menuName, $item, $isInverse = true)
 {
     $manipulator = new MenuManipulator();
     $breadcrumbs = $manipulator->getBreadcrumbsArray($item);
     if ($breadcrumbs[0]['label'] == $menuName) {
         unset($breadcrumbs[0]);
     }
     if (!$isInverse) {
         $breadcrumbs = array_reverse($breadcrumbs);
     }
     return $breadcrumbs;
 }
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testBreadcrumbsArrayInvalidData()
 {
     $manipulator = new MenuManipulator();
     $manipulator->getBreadcrumbsArray($this->pt1, array(new \stdClass()));
 }