2009年7月10日星期五

Re: [fw-mvc] Handle missing modules with Zend_Controller_Plugin_ErrorHandler

Technically speaking, if a module is missing, then a controller (the
actual dispatchable thing), is missing. The existence of a module is
not really known until it is attempted to be dispatched. Does that make
sense?

If you want to know if a module actually exists or not, you'll have to
do some more up-front logic in your bootstrap, for example, like
bootstrapping a module.

See:
http://framework.zend.com/manual/en/zend.application.available-resources.html#zend.application.available-resources.modules

But note: if you bootstrap your modules in this manner, this means that
for every request (even when a specific module is not needed by that
request), its still bootstrapped.

The better question is: what are you trying to do in your error
controller that you cannot already do? In general, a 404 is a 404 is a
404, regardless of which controller/module was requested.

-ralph

Ian Munday wrote:
> Hi
>
> I'm using Zend_Controller_Plugin_ErrorHandler to handle 404 errors.
>
> My default route is:
>
> <?php
> ...
> $route = new Zend_Controller_Router_Route(
> ':lang/:module/:controller/:action/*',
> array(
> 'action' => 'index',
> 'controller'=>'index',
> 'module'=>'default',
> 'lang'=>$lang));
> ...
> ?>
>
> This works fine for where an invalid controller is specified, but it doesn't
> handle missing modules.
>
> I see that this class is meant to, "Handle exceptions that bubble up based
> on missing controllers, actions, or application errors, and forward to an
> error handler", and that the following constants are utilised:
>
> <?php
> ...
> const EXCEPTION_NO_CONTROLLER = 'EXCEPTION_NO_CONTROLLER';
> const EXCEPTION_NO_ACTION = 'EXCEPTION_NO_ACTION';
> const EXCEPTION_OTHER = 'EXCEPTION_OTHER';
> ...
> ?>
>
> Has anybody had experience of making this also handle missing modules?
>
> Regards,
>
> Ian

没有评论: