Zend\Mvc\Application::init

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend\Mvc\Application::init

Perosurac
Hi there,

In the "init" function (of the "application" objet), there is this line :
$serviceManager->get('ModuleManager')->loadModules();

If I understand, the $serviceManager->get function is to retrieve a "service". In this case, where is the service 'ModuleManager' defined ?


Same thing with the next line :
return $serviceManager->get('Application')->bootstrap();

Where is 'Application' defined ?

Thanks.

Perosurac

"We must become the change we want to see in the world." (Gandhi)

http://www.thezeitgeistmovement.com/
Reply | Threaded
Open this post in threaded view
|

Re: Zend\Mvc\Application::init

weierophinney
Administrator
On Tue, Dec 18, 2012 at 12:50 PM, Perosurac <[hidden email]> wrote:
> In the "init" function (of the "application" objet), there is this line :

Which line? (did not get in the email...)

> If I understand, the $serviceManager->get function is to retrieve a
> "service". In this case, where is the service 'ModuleManager' defined ?

Zend\Mvc\Service\ServiceManagerConfig contains the base configuration
for required services, which includes the SharedEventManager,
EventManager, and ModuleManager. Other services are defined in the
ServiceListenerFactory of that same namespace, and that includes the
"Application" service itself.


--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Zend\Mvc\Application::init

EvanDotPro
On Tue, Dec 18, 2012 at 11:57 AM, Matthew Weier O'Phinney
<[hidden email]> wrote:

>
> On Tue, Dec 18, 2012 at 12:50 PM, Perosurac <[hidden email]> wrote:
> > In the "init" function (of the "application" objet), there is this line :
>
> Which line? (did not get in the email...)
>
> > If I understand, the $serviceManager->get function is to retrieve a
> > "service". In this case, where is the service 'ModuleManager' defined ?
>
> Zend\Mvc\Service\ServiceManagerConfig contains the base configuration
> for required services, which includes the SharedEventManager,
> EventManager, and ModuleManager. Other services are defined in the
> ServiceListenerFactory of that same namespace, and that includes the
> "Application" service itself.

To clarify the reasoning behind this -- it's so that only the services
absolutely necessary are configured prior to modules being loaded.
This allows you to override literally _any_ other service, including
the Application from within a module. Powerful stuff. :)

--
Evan Coury

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Zend\Mvc\Application::init

Marco Pivetta
Very powerful indeed!

Having these base elements of the framework specified as services allows
you to even swap them out and replace them with your customized ones :)

For example, I even swap out the ServiceManager itself in some applications!

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/



On 18 December 2012 20:47, Evan Coury <[hidden email]> wrote:

> On Tue, Dec 18, 2012 at 11:57 AM, Matthew Weier O'Phinney
> <[hidden email]> wrote:
> >
> > On Tue, Dec 18, 2012 at 12:50 PM, Perosurac <[hidden email]> wrote:
> > > In the "init" function (of the "application" objet), there is this
> line :
> >
> > Which line? (did not get in the email...)
> >
> > > If I understand, the $serviceManager->get function is to retrieve a
> > > "service". In this case, where is the service 'ModuleManager' defined ?
> >
> > Zend\Mvc\Service\ServiceManagerConfig contains the base configuration
> > for required services, which includes the SharedEventManager,
> > EventManager, and ModuleManager. Other services are defined in the
> > ServiceListenerFactory of that same namespace, and that includes the
> > "Application" service itself.
>
> To clarify the reasoning behind this -- it's so that only the services
> absolutely necessary are configured prior to modules being loaded.
> This allows you to override literally _any_ other service, including
> the Application from within a module. Powerful stuff. :)
>
> --
> Evan Coury
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Zend\Mvc\Application::init

Perosurac
Now it's clear in my mind

Thanks a lot for the job guys !

Perosurac

"We must become the change we want to see in the world." (Gandhi)

http://www.thezeitgeistmovement.com/