Fixed canGetProperty() and canSetProperty() returns false for yii\db\BaseActiveRecord attributes

This commit is contained in:
Klimov Paul
2016-08-30 17:39:23 +03:00
parent cd26cbf11a
commit 75439d367d
3 changed files with 38 additions and 1 deletions

View File

@ -230,6 +230,28 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
return null;
}
/**
* @inheritdoc
*/
public function canGetProperty($name, $checkVars = true, $checkBehaviors = true)
{
if ($this->hasAttribute($name)) {
return true;
}
return parent::canGetProperty($name, $checkVars, $checkBehaviors);
}
/**
* @inheritdoc
*/
public function canSetProperty($name, $checkVars = true, $checkBehaviors = true)
{
if ($this->hasAttribute($name)) {
return true;
}
return parent::canSetProperty($name, $checkVars, $checkBehaviors);
}
/**
* PHP getter magic method.
* This method is overridden so that attributes and related objects can be accessed like properties.