Yii2: behaviors cannot catch non existing owner properties with __get(), __set() and __call()

Created on 11 May 2016  路  3Comments  路  Source: yiisoft/yii2

Hi
first, I would like to thank you for your efforts...

I want catch non existing property of a model in my behavior.
I trid it:
(in my behavior:)

public function __get($name) {
return 'Handle '.$name.' By behavior.';
}

when call $model->nonexist , I get Unknown Property exception.

I changed it to :

public function getNonexist() {
return 'Handle nonexist By behavior.';
}

It worked, but I want handle dynamic property,( for example Based on behavior config ...).
too, I also checked __call for non exiting owner method , but not worked.
Is it a bug , or is there another way?

Most helpful comment

Its not bug. You must implement/override canGetProperty().

All 3 comments

write __isset function

__isset not worked too.

Its not bug. You must implement/override canGetProperty().

Was this page helpful?
0 / 5 - 0 ratings