public static function populateModel($data) { $model = parent::populateModel($data); if (isset($data['width']) && $data['height']) { $model->size = $data['width'] . 'x' . $data['height']; } return $model; }
/** * 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; }
/** * @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; }