2009年7月21日星期二

Re: [fw-mvc] Disable initializing a module resource

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Tuesday, 21 July 2009, 12:39 AM +0300):
> I am working with Zend_Application and multiple modules.
>
> I am trying to accomplish one thing with module bootstraps.
>
> I have one _initThing method in couple of module bootstraps. I want to
> init Thing resource on all modules only per request, and not automatted
> from an action like that:
>
> $bootstrap = $this->getInvokeArg('bootstrap');
> $resource = $bootstrap->getPluginResource('modules');
> $moduleBootstraps = $resource->getExecutedBootstraps();
> foreach($moduleBootstraps as $moduleBootstrap)
> if($moduleBootstrap->hasResource('Thing'))
> $moduleBootstrap->getResource('Thing');
>
> Problem is that resource is initialized automatically when the module
> bootstrap is loaded. How can i avoid one module bootstrap resource to
> get initialized automatically ?

Don't prefix it with _init, andmake it public. Then you can can simply
check for the existence of the method, execute it, and use the return
value.

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: