I'm writing an admin section to a site using CodeIgniter. I am writing an Admin
class that extends the Controller
class, and then controllers for admin pages will extend Admin
. I do this because I want the Admin
class to check the user's session to make sure he is logged in -- and if not, to show the login page and abort initialization of the class.
To me, that seems like a nice abstraction -- not worrying about the user being logged in for any of the administration pages and functions, just writing them and letting the super class worry about it. But how should I do this?
If I throw an exception from the Admin
constructor, will that stop the sub class extending it from being created? is there a better way to do this? @anyone who has used MVC before, have you dealt with something like this before?