简体   繁体   中英

Plugin managers in Zend Framework 2

I am going to write my own abstract factory, similar to the Zend\\Log\\LoggerAbstractServiceFactory . I noticed that this abstract factory works with plugin managers , but I am wondering exactly what the purpose of plugin managers is - both in general and in this particular example. The Zend\\Log namespace includes multiple plugin managers such as WriterPluginManager and ProcessorPluginManager , while the Zend\\Log\\Writer namespace includes the FormatterPluginManager class. Basically I am confused as to what exactly these plugin managers do.

I know that there are several plugin managers for controller plugins, view helpers, etc., and I noticed that a plugin manager is a specialized service locator because the Zend\\ServiceManager\\AbstractPluginManager class extends Zend\\ServiceManager\\ServiceManager .

So my question is: what is the purpose of plugin managers, both in general, and in the concrete example of the Zend\\Log namespace? I couldn't really find any documentation on this.

A plugin manager is a special service manager which returns a particular type of services. They define a validatePlugin() method which checks that the service is indeed of the correct type. From the examples you gave, WriterPluginManager returns log writers and ProcessorPluginManager unsurprisingly returns log processors.

You shouldn't need to worry too much about the specifics of this as long as your abstract factory returns classes implementing the correct interface.

pluginManager created to manage controller plugin . controller plugin execute on all request for example if you want check authorization or log , best place is controller plugin or any task should do on all request .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM