Welcome Guest, Not a member yet? Register   Sign In
Full abstract factory pattern to use for Code Igniter modes
#1

[eluser]Unknown[/eluser]
Hello,

I'm creating a website where I'm using MongoDB as database, buy I also want to be able to use any other storage system in the future, so I would like to use a full implementation of the abstract factory pattern. With a full implementation I refer to this:

- "Database_factory" abstract class, which should be use by the client code (controller) to create a factory object.
- "Mongodb_factory" class, which extends Database_factory class.

- "Customers" abstract class that represents a set of queries.
- "Mongodb_customers" class that implements "Customers" class. "Mongodb_customers" object should be returned by the "Mongodb_factory".

I know exactly how to do this with pure OO PHP. But I don't know how to merge it with the models arquitecture that CodeIgniter provides.

It would be easy to just have the "Customers" abstract class and then the "Mongodb_customers" to implement it, but I want to make use of the factories too.

When you need a model in CodeIgniter, you just use "$this->load->model('my_model');" and use its functions, but how to create a factory object, and make it return the concrete model you need, which you use through an interface (abstract class)?

Is there any chance to achieve this?

Thanks to all of you people.




Theme © iAndrew 2016 - Forum software by © MyBB