ZF-8466: improvement method Zend_Application_Bootstrap_BootstrapAbstract::setOptions()

Issue Type: Patch Created: 2009-12-04T07:51:04.000+0000 Last Updated: 2012-11-20T21:38:01.000+0000 Status: Open Fix version(s): Reporter: Ramon Henrique Ornelas (ramon) Assignee: None Tags: - Zend_Application

Related issues: - ZF-8175

Attachments: - BootstrapAbstract.patch


<pre class="highlight">
 * 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);

    foreach ($options as $key => $value) {
        $method = 'set' . strtolower($key);

        if (in_array($method, $methods)) {
        } 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:

<pre class="highlight">
application = "xxx"
container   = "xxx"
options     = "xx" 
pluginloader = "xxx"


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


Too think more friendly first patch, equal resolved in Zend_Form_Element::setOptions()

<pre class="highlight">
if (in_array($method, array('setTranslator', 'setPluginLoader', 'setView'))) {
    if (!is_object($value)) {

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()

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.