fuelphp-storage / fuelphp

FuelPHP framework
http://fuelphp.com
MIT License
274 stars 57 forks source link

Component custom 404 page #56

Open sagikazarmark opened 10 years ago

sagikazarmark commented 10 years ago

Currently only the root component has 404 page (or any other http exception page).

IMO the exceptions handled in index.php should look for the component's router first where the request went.

WanWizard commented 10 years ago

The assumption has been that that an Application (with all it's components) is a unity, and if you have several (like an environment with a separate frontend and backend), you will have two applications.

I think it may be a better solution to treat those exceptions as events, and simply trigger an event from index.php when the exception occurs. You then have a generic solution, and every component, controller or even method can attach a custom eventhandler to deal with the exception.

sagikazarmark commented 10 years ago

Hm, the assumption is a bit weird to me, but I can live with that. I am currently creating an admin component which can be itself an application and also can be a component of an other application. This way you can use this component for any sites wither having a public site or some sort of internal system (CRM, ERP, etc).

I am a bug fan of event-driven design, so I'm not against it, however I also like the exceptions so it would be good if a thrown http exception could be translated into an event.

WanWizard commented 10 years ago

That is exactly the idea. You have an application, which contains one or more components, in a hierarchy. In your case, but have an application.

I didn't say "remove the exceptions", it said "handle the exception by triggering an event". Which I think is exactly what you suggest. :grinning:

sagikazarmark commented 10 years ago

We are on the same line then. ;)

WanWizard commented 10 years ago

Yup. "Great minds think alike". :+1: