Welcome Guest, Not a member yet? Register   Sign In
How CI passes loaded objects to newly instantiated ones?
#1

[eluser]Imkow@CN[/eluser]
I realize that CI passes every loaded object(e.g. language,config, models, libraries) to a newly instantiated one(e.g. $this->model_name will has its $this->model_name->language object).
Will this practice break the encapsulation of the object design?
Is there any way to control/manage this process?
#2

[eluser]coolfactor[/eluser]
Quote:Will this practice break the encapsulation of the object design?

Can you clarify this question? Provide some examples of what you want to do?

Certain objects are made available to other objects that you load (libraries, views, models), but keep in mind that everything that is accessible in your controller is always available using the following:

Code:
$CI = get_instance();
$CI->object_your_want_to_access;

$CI is your controller instance (CI stands for "CodeIgniter", but more realistically for "controller instance")
#3

[eluser]Imkow@CN[/eluser]
Thanks for replying. Here is one of my situations. I have built a model(named PEW_Lang) backed by database for handling languages and internationalization problems. It's basically a replacement for CI's language lib.
As CI passing every object to the new ones, after the model loaded code like "$this->pew_lang->language" really can cause problems because i might want to use the word "language" as a property of the pew_lang object - previouly defined objects might cause name conflict with properties of the new object.

Does CI provide a way to prevent this? or I have to do something methodologically?




Theme © iAndrew 2016 - Forum software by © MyBB