46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
|
|
class PreorderStatusflagValue extends mfBaseModel {
|
|
private $preorder;
|
|
|
|
protected function afterSave() {
|
|
//echo __METHOD__."\n";
|
|
if(!property_exists($this->_old_data, "value") || $this->_old_data->value != $this->data->value) {
|
|
$history = PreorderHistoryModel::create([
|
|
"preorder_id" => $this->data->preorder_id,
|
|
"key" => "preorderstatusflag-".$this->data->flag_id."-value",
|
|
"old_value" => property_exists($this->_old_data, "value") ? $this->_old_data->value : null,
|
|
"new_value" => $this->data->value
|
|
]);
|
|
|
|
$history->save();
|
|
|
|
}
|
|
|
|
$preorder = $this->getProperty("preorder");
|
|
//echo "[{$preorder->_ruid}] flagvalue aftersave: loaded preorder\n";
|
|
$preorder->afterSave();
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
$classname = ucfirst($name);
|
|
$idfield = $name."_id";
|
|
//var_dump(mfValuecache::singleton()->cache["mfObjectmodel-$name-".$this->$idfield]);exit;
|
|
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
|
if(!$this->$name) {
|
|
$this->$name = new $classname($this->$idfield);
|
|
}
|
|
|
|
if($this->$name->id) {
|
|
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
|
return $this->$name;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return $this->$name;
|
|
}
|
|
} |