Closed alrik11es closed 10 years ago
Eh, why is that?
The default 404.php and 500.php view files can be overridden in app, just like anything else from the core? And if you want more, you can extend both Exception classes in app too. Although the preferred why of dealing with this is to catch the exception in your index.php, like it is done by default.
There is never a need to modify framework core code.
Could you be more specific? I've tried to extend the classes from the app but didn't work. I think that the problem could be that the docs are not very clear then.
I've tried something like this in the classes root inside my app. I guess that is correct but I don't know how to override the framework to use this file instead of the default one.
namespace Fuel\Core;
class HttpNotFoundOwnException extends HttpNotFoundException
{
public function response()
{
$this->data = array();
$this->data['path'] = Uri::base(false);
return new \Response(\View::forge('errors/404.twig', $this->data), 404);
}
}
See http://fuelphp.com/docs/general/extending_core.html#/extend_and_replace
How about this?
fuel/app/classes/httpnotfoundexception.php:
class HttpNotFoundException extends Fuel\Core\HttpNotFoundException
{
public function response()
{
$this->data = array();
$this->data['path'] = Uri::base(false);
return new \Response(\View::forge('errors/404.twig', $this->data), 404);
}
}
fuel/app/bootstrap.php:
Autoloader::add_classes(array(
// Add classes you want to override here
// Example: 'View' => APPPATH.'classes/view.php',
'HttpNotFoundException' => APPPATH.'classes/httpnotfoundexception.php',
));
Thanks. Really helpful. BTW this framework is incredible keep it up!
Until now I've always had to edit HttpNotFoundException and HttpServerErrorException directly in the core without the possibility of subtract this to my app to use my own view.
The thing is that this is a module agnostic framework at this point because if I have to update the core I will overwrite this thing causing me troubles on a good framework-app separation.