Class yii\shell\YiiCaster
Inheritance | yii\shell\YiiCaster |
---|---|
Available since extension's version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-shell/blob/master/YiiCaster.php |
YiiCaster provides wrapper for casters of psysh
Public Methods
Method | Description | Defined By |
---|---|---|
castModel() | Get an array representing the properties of a model. | yii\shell\YiiCaster |
Method Details
Get an array representing the properties of a model.
public static array castModel ( \yii\db\ActiveRecord $model ) | ||
$model | \yii\db\ActiveRecord |
public static function castModel(ActiveRecord $model)
{
$attributes = array_merge(
$model->getAttributes(), $model->getRelatedRecords()
);
$results = [];
foreach ($attributes as $key => $value) {
$results[Caster::PREFIX_VIRTUAL.$key] = $value;
}
return $results;
}