2010年2月16日星期二

Re: [fw-mvc] Inject preDispatch code without explicitly declaring it in each controller

Hector,

thanks for the email reminder ;-)

So if I configure the autoloader in application.ini ahead of the
frontController, then I should be good. I'll give it a try. Thanks a
bunch!
regards,

Nathan Garlington
T&R Trailer Sales
5930 N Interstate 25
Pueblo, CO 81008

719.546.2321 T
719.423.8033 M
719.404.4697 F

nathan@tandrtrailer.com
www.tandrtrailer.com

On Tue, Feb 16, 2010 at 5:22 PM, Hector Virgen <djvirgen@gmail.com> wrote:
> Hey Nathan, please use reply all next time :)
> Anyways, what I did was I created my own "autoloader" resource that I could
> configure from within application.ini. Here's the code I used:
> http://pastie.org/828165
> And the ini settings:
> ; Module Autoloader
> resources.autoloader.namespace = "Default_"
> resources.autoloader.basePath = APPLICATION_PATH
> resources.autoloader.includeFileCache = APPLICATION_PATH
> "/../data/pluginLoaderCache.php"
> resources.autoloader.fallbackAutoloader = false
> Just modify as necessary. I'm not sure if there is already something in ZF
> that can do this for us, but this way has worked well for me.
> --
> Hector
>
>
> On Tue, Feb 16, 2010 at 4:14 PM, Nathan Garlington <garlinto@gmail.com>
> wrote:
>>
>> Ok,
>>
>> I got the plugin to work as expected, but I was unable to enable it
>> via my application.ini as per Hector's use case. The reason being that
>> the autoloader isn't yet up and running at that point (i guess?).
>>
>> So this is how I was able to invoke the class:
>>
>> $application->bootstrap();
>> $bootstrap = $application->getBootstrap();
>> $bootstrap->bootstrap('frontController');
>> $front = $bootstrap->frontController;
>> $front->registerPlugin(new Admin_Plugin_Authenticate());
>> $application->run();
>>
>> This works, but I would rather use:
>>
>> resources.frontController.plugins.authenticate =
>> "Admin_Plugin_Authenticate"
>>
>> ...in the future for other plugins. How do I ensure that the
>> autoloader is already in place before the front controller calls on
>> the plugins? As it is now, the autoloader is configured just before
>> $application->bootstrap(); is called.
>>
>> regards,
>>
>> Nathan Garlington
>> T&R Trailer Sales
>> 5930 N Interstate 25
>> Pueblo, CO  81008
>>
>> 719.546.2321 T
>> 719.423.8033 M
>> 719.404.4697 F
>>
>> nathan@tandrtrailer.com
>> www.tandrtrailer.com
>>
>>
>>
>> On Tue, Feb 16, 2010 at 2:40 PM, Nathan Garlington <garlinto@gmail.com>
>> wrote:
>> > On Tue, Feb 16, 2010 at 2:35 PM, Hector Virgen <djvirgen@gmail.com>
>> > wrote:
>> >> Good point, but if you don't need the controller at all (depends on how
>> >> the
>> >> OP decides to handle the unauthenticated scenario) then you can skip
>> >> dispatching the controller and redirect at routeShutdown (the earlier
>> >> point
>> >> in which you'll know where the user is going).
>> >
>> > Yes, in my particular app, the only controller not needing
>> > authentication is the LoginController, so for me, the front controller
>> > plugin scenario is perfect.
>> >
>> > regards,
>> >
>> > Nathan Garlington
>> > T&R Trailer Sales
>> > 5930 N Interstate 25
>> > Pueblo, CO  81008
>> >
>> > 719.546.2321 T
>> > 719.423.8033 M
>> > 719.404.4697 F
>> >
>> > nathan@tandrtrailer.com
>> > www.tandrtrailer.com
>> >
>
>

没有评论: