I've spent a little while trying to trace my way through the ZF2 code and documentation, but I can't seem to find an explanation for a way to extend the configuration using the global config for an instance of Zend\\Service\\AbstractPluginManager
when it has been registered as a service manager with the service listener.
An overview of the classes I have created:
AssetManager\\AssetFilterPluginManager
: extends AbstractPluginManager
AssetManager\\Service\\AssetFilterManagerFactory
: A factory extending Zend\\Mvc\\Service\\AbstractPluginManagerFactory
with the const PLUGIN_MANAGER_CLASS
set to "AssetManager\\AssetFilterManagerFactory"
AssetManager\\AssetFilterProviderInterface
: The module feature interface
In the config/module.config.php
I have configured the service listener as follows:
'service_listener_options' => array(
array(
'service_manager' => 'AssetFilterManager',
'config_key' => 'asset_filters',
'interface' => 'AssetManager\AssetFilterProviderInterface',
'method' => 'getAssetFilterConfig',
),
),
The service manager config contains the definition of AssetFilterManager
:
'service_manager' => array(
'factories' => array(
'AssetFilterManager' => 'AssetManager\Service\AssetFilterManagerFactory',
),
),
Having read through the usage of these options in the view helpers code, this is my understanding of how the configuration should be laid out. Looking at the config_key
option in the service listener options, it would seem that the configuration should be passed to the plugin manager to configure the services, but I can't determine where or whether this happens. Perhaps I'm misunderstanding the implementation.
My goal is a pluggable service manager extension that functions much like Zend's built-in controller plugins and view helper managers. If there's anyone with any greater experience using these features than me, I would appreciate any insight.
You cannot configured the service listener in the config/module.config.php, service_listener_options is part of config/application.config.php. This configuration is readed before modules initialization. See work example here . You must configured the service listener in your Module.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.