Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 2 - Drivers :: example
#10

[eluser]Vheissu[/eluser]
[quote author="Eric Barnes" date="1297564786"][quote author="Vheissu" date="1297495752"]
Very helpful. I understand how they work and how to make drivers, etc. The one thing I don't understand is how you create functions in the main driver class that loads the child drivers to make it a true driver system where drivers implement the main driver abstract class and must implement those methods.
[/quote]

A good example of this is the new Cache driver. Check out the main cache file and you can see how it is calling the child from the parent:
Quote: public function get($id)
{
return $this->{$this->_adapter}->get($id);
}

In my mind this should really be an interface so you can guarantee the drivers implement the same methods or at least the methods you are expecting. But I think it was not set up this way so it would be the most flexible.[/quote]

Ah, very interesting. Thank you for that Eric! So you can call the child from the parent, I was wondering if you could because everywhere else I read it said that you couldn't. Didn't really dig too much, but _adapter will be most useful definitely.

Is adapter the currently selected child driver? So if I have an auth class and a Facebook driver, and I use the Facebook driver, _adapter will be the Facebook class? How hard do you think it would be to extend native CI drivers capability and make it an interface or abstract class for child drivers to implement?

Is the drivers library even extendible? It might be more trouble than it's worth, I guess the current way they work is fine, it's better than just using a standard library at least.


Messages In This Thread
Codeigniter 2 - Drivers :: example - by El Forum - 09-28-2010, 05:07 PM
Codeigniter 2 - Drivers :: example - by El Forum - 09-28-2010, 06:08 PM
Codeigniter 2 - Drivers :: example - by El Forum - 09-28-2010, 07:24 PM
Codeigniter 2 - Drivers :: example - by El Forum - 09-28-2010, 10:01 PM
Codeigniter 2 - Drivers :: example - by El Forum - 02-11-2011, 09:13 AM
Codeigniter 2 - Drivers :: example - by El Forum - 02-11-2011, 09:36 AM
Codeigniter 2 - Drivers :: example - by El Forum - 02-11-2011, 09:49 AM
Codeigniter 2 - Drivers :: example - by El Forum - 02-11-2011, 07:29 PM
Codeigniter 2 - Drivers :: example - by El Forum - 02-12-2011, 02:39 PM
Codeigniter 2 - Drivers :: example - by El Forum - 02-12-2011, 03:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB