• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
elegant way design controllers for medium-sized app?

#1
[eluser]webdevguy32[/eluser]
I have an app where different roles can perform operations on the database. for example, the administrator can create people and manage people. People can manage themselves(people). Instructors need to view people and give people credit for attending a lecture.

So I have controller MAIN handling everything so far (I am new to OOP). Shouldn't I throw off control to a student controller and then test role for access to perform each method b4 they are allowed to perform it?

If so, what does that look like in my main controller?

OR, do I have the menu system simply point(link) to different controllers, like, you're in MAIN as an ADMINISTRATOR (so your URL is something like, mysite.com/main/somemethod. Then have the menu link to <a href="student/manage">Manage</a> where that link takes the user to the manage method in the student controller and in that method, I test for authorization/access to be able perform that operation?

Starting to like this OOP stuff

Thanks.

#2
[eluser]davidMC1982[/eluser]
I would extend Codeigniter's Controller class with MY_Controller, build my auth system as a library that gets loaded in MY_Controller and performs its ACL checks in the constructor. I would then make sure that I'm putting logic that belongs in the model, in the model. The methods you use for "manage people" are going to be the same whether it's an Administrator or someone else doing the managing.

My controllers would then extend MY_Controller and handle a specific feature (or group of features).

#3
[eluser]webdevguy32[/eluser]
David, I understand that on a conceptual level. Being new to oop, I don't know what that looks like in actual code. Do you know of any links where I can see the code in action, of something similar to what you're talking about?

Many thanks.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.