Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Helper/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,14 @@ public function findHelper($proxy, $strict = true)
return false;
}

$helper = $plugins->get($proxy);
$class = get_class($helper);
$helper = $plugins->get($proxy);
$container = $this->getContainer();
$hash = spl_object_hash($container);

if (!isset($this->injected[$class])) {
if (!isset($this->injected[$hash])) {
$helper->setContainer();
$this->inject($helper);
$this->injected[$class] = true;
$this->injected[$hash] = true;
}

return $helper;
Expand Down
22 changes: 22 additions & 0 deletions test/Helper/Navigation/NavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,28 @@ public function testRenderInvisibleItem()
$this->assertTrue(strpos($render, 'p2') !== false);
}

public function testMultipleNavigations()
{
$sm = new ServiceManager();
$nav1 = new Container();
$nav2 = new Container();
$sm->setService('nav1', $nav1);
$sm->setService('nav2', $nav2);

$helper = new Navigation();
$helper->setServiceLocator($sm);

$menu = $helper('nav1')->menu();
$actual = spl_object_hash($nav1);
$expected = spl_object_hash($menu->getContainer());
$this->assertEquals($expected, $actual);

$menu = $helper('nav2')->menu();
$actual = spl_object_hash($nav2);
$expected = spl_object_hash($menu->getContainer());
$this->assertEquals($expected, $actual);
}

/**
* Returns the contens of the expected $file, normalizes newlines
* @param string $file
Expand Down

0 comments on commit c188616

Please sign in to comment.