Welcome Guest, Not a member yet? Register   Sign In
Community Auth: Limitation for classes
#1
Question 

Hi friends!
I started to learn CodeIgniter few days ago, and first library that I plugged in was Community Auth.

The way in which this library serves Authentication functions is a little bit confusing me. I expect something like that: if I once plug-in third library, their functions and methods will be available everywhere at the application (means in each Controller). Instead of this, how I learned, Authentication functions will be available to use only when extending from MY_Controller (from Community Auth).
But what will be if I need to use another third-library with another ancestor class? For example in C++ it is possible to use Multiple inheritance (which is however not good style of coding), but this is not possible in PHP.

Therefore I have question:
Whether I necessarily need to extend my controller from MY_Controller to use (for example) "is_logged_in" function ?

Sorry, if I missed something important in guideness, please correct me.
Thanks in advance.
Reply
#2

Yes and no. You probably noticed that MY controller is extending Auth controller and that is extending CI controller. The functions are actually in Auth controller, so in theory your controller could extend Auth controller directly. That said it is very common to set up a base controller like MY controller, and super easy to have all of your controllers extend it. Since by default you would always extend CI controller, your simply doing a substitution.
Reply
#3

(11-13-2017, 06:57 PM)skunkbad Wrote: Yes and no.

Thanks mate! Hopes inheritence from MY_Controller will not limit  functionality of my application, as I need to check user rights on every route, because I writing backend for site.

Also many thanks for your good work! Your code is well documented and easy to understand.
Reply
#4

(11-13-2017, 10:07 PM)Yuribtr Wrote:
(11-13-2017, 06:57 PM)skunkbad Wrote: Yes and no.

Thanks mate! Hopes inheritence from MY_Controller will not limit  functionality of my application, as I need to check user rights on every route, because I writing backend for site.

Also many thanks for your good work! Your code is well documented and easy to understand.

Thanks for your comments. If you come across a hurdle and need some advice, let me know and we'll work out a solution. I think if you spend some time with Community Auth, you'll see that it's really easy to make custom functionality.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB