Yes, you will be able to do so but you’ll need to override default attributes method that’s returning public and non-static properties currently:
/**
* Returns the list of attribute names.
* By default, this method returns all public non-static properties of the class.
* You may override this method to change the default behavior.
* @return array list of attribute names.
*/
public function attributes()
{
$class = new \ReflectionClass($this);
$names = array();
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
$name = $property->getName();
if (!$property->isStatic()) {
$names[] = $name;
}
}
return $names;
}
However, the method above is a getter. I was asking about a setter - setting some attribute that during rendering would be attached (injected) into CModel.
Setter relies on what is returned from attributes so it’s possibe to achieve what you need. So you’ll end up with something like FlexibleModel extends Model {} that you’ll use as a base for such models.