Welcome Guest, Not a member yet? Register   Sign In
Writing Admin/User/Public controllers to insure authentication
#4

(12-23-2014, 04:40 AM)Avenirer Wrote: Well... If you are talking about best practices, the best practice would be to have only a MY_Controller. If you are talking about your needs and how you see it easier to implement them your application, CodeIgniter is basic enough to allow you to do whatever you want and make it as complex as you want, if you know how. Smile
Avenirer, I'm guessing that's your article? It's nice. I'm inclined to trust you but just want to be sure. Perhaps you could more specifically address this question that I asked:
'sneakyimp Wrote:I'm wondering if using hooks as described in the article is in fact the recommended way to go.
There seem to be many ways to accomplish something in CI. I'm primarily interested in avoiding techniques that require special effort every time I have to upgrade CI to the next version. With that in mind, putting my custom code in files that are not touched by the CI devs seems very important to me. I would also agree that putting a lot of code in a configuration file seems like a bad idea. Perhaps you could explain why you think using hooks is the best approach. Is this code safe from a CI core upgrade?

As for my plan to use more than one controller, it seems pretty apparent to me that my site is likely to have session-related functionality whether visitors are logged in or not. It further seems likely that I'll have distinct functionality for administrators versus visiting authenticated users. I expect Admin_Controller to inherit from User_Controller which will inherit in turn from Basic_Controller (or something like that). If anyone thinks this is a bad idea, I'd love to know why. It seems like essentially the same thing recommended in Avenirer's article...

I also like Hobbes' suggestion of putting some code after the class definition to load the Admin_Controller (and possibly other classes). This seems simpler to me than creating an entirely separate hook and enabling hooks, etc. It has the additional advantage that it doesn't require me to alter files distributed as part of CI.
Reply


Messages In This Thread
RE: Writing Admin/User/Public controllers to insure authentication - by sneakyimp - 12-23-2014, 10:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB