Skip to content
This repository has been archived by the owner on Feb 11, 2018. It is now read-only.

Commit

Permalink
Fix issue #22
Browse files Browse the repository at this point in the history
  • Loading branch information
flobb committed Feb 27, 2015
1 parent b945901 commit 958105e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Twig/MenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,17 @@ public function renderAsBreadcrumb($menu, array $options = array())
$itemFilterIterator = new CurrentItemFilterIterator($treeIterator, $this->matcher);
$itemFilterIterator->rewind();

// Extract the items for the breadcrumb
// Watch for a current item
$current = $itemFilterIterator->current();

$manipulator = new MenuManipulator();
$breadcrumbs = $manipulator->getBreadcrumbsArray($itemFilterIterator->current());
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) {
Expand Down

0 comments on commit 958105e

Please sign in to comment.