diff --git a/library/Zend/View/Helper/Navigation.php b/library/Zend/View/Helper/Navigation.php index f77caffca03..b0185427999 100644 --- a/library/Zend/View/Helper/Navigation.php +++ b/library/Zend/View/Helper/Navigation.php @@ -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; diff --git a/tests/ZendTest/View/Helper/Navigation/NavigationTest.php b/tests/ZendTest/View/Helper/Navigation/NavigationTest.php index 522cb527533..76f01de9da7 100644 --- a/tests/ZendTest/View/Helper/Navigation/NavigationTest.php +++ b/tests/ZendTest/View/Helper/Navigation/NavigationTest.php @@ -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