ZF-11664: Allow manually setting Zend_Navigation_Page_Mvc::isActive
Description
Calling setActive(false) on navigation page will still let isActive() execute internal mechanism to detect if page is active. Solution would be if setActive($active) would support 3 value true/false/null, where null should be default null.
My implementation:
<?php
class XTZend_Navigation_Page_Mvc extends Zend_Navigation_Page_Mvc
{
protected $_active = null;
public function isActive($recursive = false)
{
if (is_null($this->_active)) {
return parent::isActive($recursive);
}
return $this->_active;
}
}
Comments
Posted by Frank Brückner (frosch) on 2011-08-13T13:26:20.000+0000
I will look at this.
Posted by Frank Brückner (frosch) on 2011-08-13T14:18:24.000+0000
Hi Martin, your implementation breaks the option to check to recursively:
Posted by Martin Minka (k2s) on 2011-08-15T09:23:50.000+0000
I think it is because my code could return NULL which is then compared in unit test with === to FALSE. Following code will always return TRUE or FALSE.
Posted by Frank Brückner (frosch) on 2011-08-15T10:14:06.000+0000
Now ``` is never "false" and the all the code from Zend_Navigation_Page_Mvc::isActive() executed. Your fix brings no changes to the old behavior.
Posted by Martin Minka (k2s) on 2011-08-15T14:53:49.000+0000
sorry, I don't understand what you mean. Does it not fix the "passing test" issue or you mean that it is not changing the fact that current Zend_Navigation_Page accepts only $page->setActive(true), but ignores $page->setActive(false);
Maybe I explained it not good enough, but my suggested code was/is only proposal how to change it, the main point is that $page->setActive(false); should work the same way as $page->setActive(true);. If it was set manualy it should not execute all the detection code in Zend_Navigation_Page_Mvc.
current implementation:
my suggestion:
I am not sure what exactly should be returned if $page->isActive(true), but it is more natural to return TRUE/FALSE if it was set manualy without to cascade. If the programmer wants to cascade, he should not set it manualy with setActive();
Posted by Frank Brückner (frosch) on 2011-08-15T15:45:56.000+0000
Hi Martin, thanks for your explanation. Here is another unit test:
Posted by Frank Brückner (frosch) on 2011-11-14T20:12:03.000+0000
Fix and unit tests added.
Posted by Adam Lundrigan (adamlundrigan) on 2012-06-01T01:20:55.000+0000
Fixed in trunk (1.12.0): r24857