priocrou
(Priocrou)
1
Hey,
is it possible to tell Yii::import to import the class only for the class that called import?
Example:
TestComp:
init() {
Yii::import(application...model.MyModel);
}
test() {
$m = new MyModel; //this should work
}
TestController:
$comp = new TestComp;
$m = new MyModel; //this should fail, because MyModel should be only available in TestComp
Is it possible to realize this with Yii::import?
Ankit_Modi
(Ankit Modi)
2
if you want to include another model then please try it…i am not sure it’s works or not.
Yii::import('application.models.MyModel')
class TestComp extends BaseTestComp:
{
}
After you import a class it’s available in every scope, not just in the class or method where it was imported. That’s the way PHP works, not Yii.
An autoloader imports a class when it is first used.