简体   繁体   中英

zend framework 2 - use global method

i need one function which i use in views, hydrator, some controllers and so on... Where i can put it?

Where it would be the best add that can be maintained PHP OOP and zend 2 architecture?

Thanks

It sounds like you should be looking at the Zend\\ServiceManager . You can register factories (functions) and services in the service manager, and technically access them from anywhere in your application. Your class would need to implement the ServiceLocatorAwareInterface in order to access the service manager, OR you would pass/inject the service into your class/model/hydrator/etc.

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