本文整理汇总了PHP中BaseModel::populateModel方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::populateModel方法的具体用法?PHP BaseModel::populateModel怎么用?PHP BaseModel::populateModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::populateModel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populateModel
public static function populateModel($data)
{
$model = parent::populateModel($data);
if (isset($data['width']) && $data['height']) {
$model->size = $data['width'] . 'x' . $data['height'];
}
return $model;
}
示例2: populateModel
/**
* Populates a new model instance with a given set of attributes.
*
* @static
* @param mixed $values
* @return BaseModel
*/
public static function populateModel($values)
{
if (isset($values['fields'])) {
$fields = $values['fields'];
unset($values['fields']);
}
$model = parent::populateModel($values);
if (isset($fields)) {
$model->setFields($fields);
}
return $model;
}
示例3: populateModel
/**
* @inheritDoc BaseModel::populateModel()
*
* @param mixed $values
*
* @return BaseModel
*/
public static function populateModel($values)
{
// Strip out the element record attributes if this is getting called from a child class based on an Active
// Record result eager-loaded with the ElementRecord
if (isset($values['element'])) {
$elementAttributes = $values['element'];
unset($values['element']);
}
$model = parent::populateModel($values);
// Now set those ElementRecord attributes
if (isset($elementAttributes)) {
if (isset($elementAttributes['i18n'])) {
$model->setAttributes($elementAttributes['i18n']);
unset($elementAttributes['i18n']);
}
$model->setAttributes($elementAttributes);
}
return $model;
}