ZF-6704: We cant setup plugin options for Zend_Application_Resource_Frontcontroller


in Zend_Application_Resource_Frontcontroller near line 90. where the plugin is set, we can see no option can be pass to the plugin from the config file.

Actually : resources.frontController.plugins.myplugin = "My_Plugin" resources.frontController.plugins.errorhandler = "Zend_Controller_Plugin_ErrorHandler"

case 'plugins': foreach ((array) $value as $pluginClass) { $plugin = new $pluginClass(); $front->registerPlugin($plugin); } break;

I transfort that to like this :

resources.frontController.plugins.myplugin = "My_Plugin" (Old way alway work if no data need to be set) resources.frontController.plugins.errorhandler.classname = "Zend_Controller_Plugin_ErrorHandler" (new way to add options to the plugin.) resources.frontController.plugins.errorhandler.options.module = "default" resources.frontController.plugins.errorhandler.options.controller = "error" ...

case 'plugins': foreach ((array) $value as $pluginClass) { if (is_array($pluginClass)){ if (!isset($pluginClass['options'])){ $pluginClass['options'] = array(); } $plugin = new $pluginClass'classname'; }else{ $plugin = new $pluginClass(); } $front->registerPlugin($plugin); } break;


The resource was never designed to do this. The reason is because there is no standard constructor argument for plugins -- meaning that we don't have a single approach that will work for any plugin referenced.

If you need to configure a given plugin, you have two options:

  • Create a resource method or plugin that does this work for you. It might pull configuration options from the bootstrap and pass them to selected plugins, or simply instantiate the plugins directly and pass them into the front controller.
  • Extend existing plugins to specify your desired defaults, and then specify this pre-configured plugin class to the front controller resource.