YiiBooster
YiiBooster copied to clipboard
sortableAttribute as getter in CActiveDataProvider
I want use getter in CActiveRecord as sortableAttribute. For do this please change in TbExtendedGridView
/**
*### .getAttribute()
*
* Helper function to get an attribute from the data
*
* @param CActiveRecord $data
* @param string $attribute the attribute to get
*
* @return mixed the attribute value null if none found
*/
protected function getAttribute($data, $attribute)
{
if ($this->dataProvider instanceof CActiveDataProvider)
{
if ($data->hasAttribute($attribute))
{
return $data->{$attribute};
}
$method = 'get' . ucfirst($attribute);
if (is_object($data) && method_exists($data, $method))
{
return call_user_func([$data, $method]);
}
}
if ($this->dataProvider instanceof CArrayDataProvider || $this->dataProvider instanceof CSqlDataProvider) {
if (is_object($data) && isset($data->{$attribute})) {
return $data->{$attribute};
}
if (isset($data[$attribute])) {
return $data[$attribute];
}
}
return null;
}
what is this ... what do you need ...!