ZF-8466: improvement method Zend_Application_Bootstrap_BootstrapAbstract::setOptions()
Description
/**
* Set class state
*
* @param array $options
* @return Zend_Application_Bootstrap_BootstrapAbstract
*/
public function setOptions(array $options)
{
$this->_options = $this->mergeOptions($this->_options, $options);
$options = array_change_key_case($options, CASE_LOWER);
$this->_optionKeys = array_merge($this->_optionKeys, array_keys($options));
$methods = get_class_methods($this);
foreach ($methods as $key => $method) {
$methods[$key] = strtolower($method);
}
if (array_key_exists('pluginpaths', $options)) {
$pluginLoader = $this->getPluginLoader();
foreach ($options['pluginpaths'] as $prefix => $path) {
$pluginLoader->addPrefixPath($prefix, $path);
}
unset($options['pluginpaths']);
}
foreach ($options as $key => $value) {
$method = 'set' . strtolower($key);
if (in_array($method, $methods)) {
$this->$method($value);
} elseif ('resources' == $key) {
foreach ($value as $resource => $resourceOptions) {
$this->registerPluginResource($resource, $resourceOptions);
}
}
}
return $this;
}
coming when the configuration of the ini file with the following options:
application = "xxx"
container = "xxx"
options = "xx"
pluginloader = "xxx"
Comments
Posted by Ramon Henrique Ornelas (ramon) on 2009-12-04T07:56:40.000+0000
Sugestion Patch 1 Assign these values mentioned above in a sort of black list of reserved words, if there is an attempt to use throws an exception.
Sugestion Patch 2 Returns only the methods of the last class ignoring the inherited methods.
Posted by Matthieu (tamat) on 2010-06-03T02:23:51.000+0000
I have thought about something like the first suggestion yesterday ! You already have proposed a patch. I vote for it !
Posted by Ramon Henrique Ornelas (ramon) on 2010-06-03T09:55:02.000+0000
@Matthieu
Too think more friendly first patch, equal resolved in Zend_Form_Element::setOptions()
I will improve patch add tests unit.
Posted by Ramon Henrique Ornelas (ramon) on 2010-06-22T13:48:55.000+0000
Attached patch ZF-8466.patch with tests, to parse.
Thanks advance.
Posted by Matthieu (tamat) on 2010-06-29T14:37:15.000+0000
@Ramon I've also noticed that the same blacklist pattern should be needed in Zend_Layout::setOptions()