lolalola
lolalola

Reputation: 3823

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

Upvotes: 0

Views: 186

Answers (1)

jon__o
jon__o

Reputation: 1519

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.

Upvotes: 1

Related Questions