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

Added separator to model in renderPartial function #5080

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/Zend/ModuleManager/ModuleManager.php
Expand Up @@ -78,6 +78,9 @@ public function onLoadModules()
} }


foreach ($this->getModules() as $moduleName => $module) { foreach ($this->getModules() as $moduleName => $module) {
if ($module == null) {
continue;
}
if (is_object($module)) { if (is_object($module)) {
if (!is_string($moduleName)) { if (!is_string($moduleName)) {
throw new Exception\RuntimeException(sprintf( throw new Exception\RuntimeException(sprintf(
Expand Down
5 changes: 4 additions & 1 deletion library/Zend/View/Helper/Navigation/Breadcrumbs.php
Expand Up @@ -172,7 +172,10 @@ public function renderPartial($container = null, $partial = null)
} }


// put breadcrumb pages in model // put breadcrumb pages in model
$model = array('pages' => array()); $model = array(
'pages' => array(),
'separator' => $this->getSeparator()
);
$active = $this->findActive($container); $active = $this->findActive($container);
if ($active) { if ($active) {
$active = $active['page']; $active = $active['page'];
Expand Down
11 changes: 11 additions & 0 deletions tests/ZendTest/ModuleManager/ModuleManagerTest.php
Expand Up @@ -89,6 +89,17 @@ public function testCanLoadSomeModule()
$this->assertSame($config->some, 'thing'); $this->assertSame($config->some, 'thing');
} }


public function testIgnoreNullModule()
{
$configListener = $this->defaultListeners->getConfigListener();
$moduleManager = new ModuleManager(array('SomeModule', null), new EventManager);
$moduleManager->getEventManager()->attachAggregate($this->defaultListeners);
$moduleManager->loadModules();
$loadedModules = $moduleManager->getLoadedModules();
$this->assertInstanceOf('SomeModule\Module', $loadedModules['SomeModule']);
$this->assertSame(count($loadedModules), 1);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do the module manager commits have to do with this? Please remove.

public function testCanLoadMultipleModules() public function testCanLoadMultipleModules()
{ {
$configListener = $this->defaultListeners->getConfigListener(); $configListener = $this->defaultListeners->getConfigListener();
Expand Down
8 changes: 8 additions & 0 deletions tests/ZendTest/View/Helper/Navigation/BreadcrumbsTest.php
Expand Up @@ -198,6 +198,14 @@ public function testRenderingPartial()
$this->assertEquals($expected, $this->_helper->render()); $this->assertEquals($expected, $this->_helper->render());
} }


public function testRenderingPartialWithSeparator()
{
$this->_helper->setPartial('bc_separator.phtml')->setSeparator(' / ');

$expected = $this->_getExpected('bc/partialwithseparator.html');
$this->assertEquals($expected, $this->_helper->render());
}

public function testRenderingPartialBySpecifyingAnArrayAsPartial() public function testRenderingPartialBySpecifyingAnArrayAsPartial()
{ {
$this->_helper->setPartial(array('bc.phtml', 'application')); $this->_helper->setPartial(array('bc.phtml', 'application'));
Expand Down
@@ -0,0 +1 @@
Page 2 / Page 2.3 / Page 2.3.3 / Page 2.3.3.1
@@ -0,0 +1,4 @@
<?php
echo implode($this->vars()->separator, array_map(
create_function('$a', 'return $a->getLabel();'),
$this->vars()->pages));