[Solar-talk] 404 Not found and handling of non-existing
controllers/action
Rodrigo Moraes
rodrigo.moraes at gmail.com
Fri Nov 23 17:42:49 CST 2007
On Nov 23, 2007 12:31 PM, Adrian Videnie wrote:
> Let me know what you think!
I was wondering why isn't the front controller like that. Here I made
a quick implementation for the idea, naming the second falback
'error_handler_controller' ( a terrible name :). That controller is
used as a fallback when: a) it is defined and b) the requested page is
not empty. Otherwise, the configured 'default' is used. Here we go:
// take the page name off the top of the path and try to get a
// controller class from it.
$page = array_shift($uri->path);
$class = $this->_getPageClass($page);
// did we get a class from it?
if (! $class) {
// put the original segment back on top.
array_unshift($uri->path, $page);
if (empty($page) || !$this->_config['error_handler_controller']) {
// try to get a controller class from the default page name
$class = $this->_getPageClass($this->_default);
} else {
// try to get a controller class for the non-empty page name
// (usually, a error handler app)
$class =
$this->_getPageClass($this->_config['error_handler_controller']);
}
}
So... it seems a good idea to to define a controller to handle wrong
requests. Specially because, currently, we have to make the default
app take care of bad requests too... Are we missing something that
would make this a bad idea?
-- rodrigo
More information about the Solar-talk
mailing list