content_update.class.php 572 B

123456789101112131415161718192021
  1. <?php
  2. class content_update {
  3. var $model_id;
  4. var $fields;
  5. var $data;
  6. function __construct($model_id,$id) {
  7. $this->model_id = $model_id;
  8. $this->fields = json_decode(Yii::$app->cache->get(CacheId::modelFieldCacheId($model_id)),true);
  9. $this->id = $id;
  10. }
  11. function update($data) {
  12. $info = array();
  13. $this->data = $data;
  14. foreach($data as $field=>$value) {
  15. if(!isset($this->fields[$field])) continue;
  16. $func = $this->fields[$field]['form_type'];
  17. $info[$field] = method_exists($this, $func) ? $this->$func($field, $value) : $value;
  18. }
  19. }
  20. }?>