Welcome Guest, Not a member yet? Register   Sign In
Is The Implementation of Codeigniter Drivers Broken?
#1

[eluser]Vheissu[/eluser]
Is the way Codeigniter drivers currently work fundamentally broken? I recently built a driver based authentication library but noticed there is a major flaw in how drivers work or I might just be picky, I don't know.

If I have a simpleauth driver, facebook driver, twitter driver how can I standarise the library if not all drivers will share the same methods as one another? What if I have an LDAP driver as well, then it gets complicated. Not all auth drivers will share the same functions in common.

Am I just being picky by thinking that $this->auth->drivername->function is a long way to do things, when I could have a parent class route the function calls so I can go $this->auth->function instead? Is it good practice to implement the functions in the parent class instead of letting the drivers have free reign?
#2

[eluser]Greg Aker[/eluser]
The Cache Drivers allow you to use either the parent, or pass in a default adapter to use.
#3

[eluser]Vheissu[/eluser]
I'm slightly confused. I did take a look at the caching drivers and how they worked, I'll try an example.

Say I have a standard auth driver called 'simpleauth' which has the following functions:
login
logout
add_user
edit_user
delete_user
create_hash
hash_password

Now say I have an auth driver called 'facebook' for Facebook type authentication. Obviously it's going to share some things in common with the other drivers for logging in, but there are other things not needed like a add_user function, edit_user function or delete_user function.

What is the best way to go about this? I noticed that the caching drivers have the functions defined in the parent class; get, save, clear, etc and then they are calling a function within the default driver. So the child classes each have a get, save, clear function too that is called.

Now with caching it seems a little more clear as caching has a set of functions each driver should do, so it's standardised, however something like an auth library can have all kinds of different functions and whatnot in each driver.

At present I am using a __call in the parent class which uses call_user_func_arr which is extremely slow, even reflection classes are slow. Am I overcomplicating this? What is a good workaround/suggestion for what I am wanting to accomplish?




Theme © iAndrew 2016 - Forum software by © MyBB