[Solar-talk] Handling 404 and exceptions
Leo Chiao
leo.chiao at gmail.com
Sat Mar 1 10:30:11 CST 2008
>
> There are two places you can override that behavior, though:
>
> * Solar_Controller_Front::_notFound() executes when it can't find the
> requested page controller.
>
> * Solar_Controller_Page::_forwardActionMethod() executes when it can't
> find a method for the requested action.
>
> (Looking at it now, the name _forwardActionMethod() describes exactly
> what is happening, but is not very intuitive -- maybe i should rename
> that to something more inviting. Maybe use Front::_pageNotFound and
> Page::_actionNotFound() as the names?)
>
Thanks for the quick reply Paul. I was aware of _notFound, but not of
_forwardActionMethod. I do agree that your suggestions for renamed methods
are more intuitive.
Regarding the _notFound method, it doesn't appear to get called when a
default page controller is defined. I could only get it to execute when no
default page controller was specified. Is this expected behavior? This is
actually what prompted me to ask the question about handling 404s and the
reason for my "unique" Front Controller config.
> $config['Solar_Controller_Front']['default'] = 'error';
> $config['Solar_Controller_Front']['routing'] = array(
> '' => 'Vendor_App_News',
> 'error' => 'Vendor_App_Error'
> );
Specifying a default page controller caused that default controller to be
displayed when accessing non-existent controllers, which is not what I
wanted. I had wanted to use the default controller to define what would
show up when accessing the base URL, but still expected the Front::_notFound
to get executed when a controller wasn't found. In addition, I didn't see
any documented examples of how people specified what controller to be run
when accessing a project by the base url (ie. the main project's domain
http://www.domain.com)
> This config setup appears to work for what I want to do, but I'm not
> > sure if it's the best or proper way:
> >
> > $config['Solar_Controller_Front']['default'] = 'error';
> > $config['Solar_Controller_Front']['routing'] = array(
> > '' => 'Vendor_App_News',
> > 'error' => 'Vendor_App_Error'
> > );
> >
> >
> > Using this config, accessing the project by it's base url would load
> > the news controller, whereas the error controller would load for non-
> > existent controllers. Is this the right way to accomplish what I am
> > trying to do?
>
> Huh -- I've not seen a setup like that before. Kinda nice. :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20080301/4736125a/attachment.html
More information about the Solar-talk
mailing list