Plugin Directory

Changeset 438768


Ignore:
Timestamp:
09/15/2011 09:28:43 PM (15 years ago)
Author:
tombenner
Message:

Calling before_save() and after_save() during MvcModel::create()

Location:
wp-mvc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-mvc/tags/1.1.1/core/models/mvc_model.php

    r390534 r438768  
    6767        }
    6868        $model_data = $data[$this->name];
     69        if (method_exists($this, 'before_save')) {
     70            if (!$this->before_save($model_data)) {
     71                return false;
     72            }
     73        }
    6974        $id = $this->insert($model_data);
    7075        $this->update_associations($id, $model_data);
     76        if (method_exists($this, 'after_save')) {
     77            $object = $this->find_by_id($id);
     78            $this->after_save($object);
     79        }
    7180        return $id;
    7281    }
  • wp-mvc/trunk/core/models/mvc_model.php

    r390534 r438768  
    6767        }
    6868        $model_data = $data[$this->name];
     69        if (method_exists($this, 'before_save')) {
     70            if (!$this->before_save($model_data)) {
     71                return false;
     72            }
     73        }
    6974        $id = $this->insert($model_data);
    7075        $this->update_associations($id, $model_data);
     76        if (method_exists($this, 'after_save')) {
     77            $object = $this->find_by_id($id);
     78            $this->after_save($object);
     79        }
    7180        return $id;
    7281    }
Note: See TracChangeset for help on using the changeset viewer.