Added some linked data in Order to cache

This commit is contained in:
Frank Schubert
2022-05-18 15:45:32 +02:00
parent 40753b6394
commit e0551d35fa
5 changed files with 111 additions and 24 deletions

View File

@@ -169,17 +169,24 @@ class Order extends mfBaseModel {
}
if($name == "owner") {
$this->owner = new Address($this->owner_id);
$this->owner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->owner_id);
if($this->owner === null) {
$this->owner = new Address($this->owner_id);
if($this->owner->id) {
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->owner_id, $this->owner);
}
}
return $this->owner;
}
if($name == "contact") {
$this->contact = new Address($this->contact_id);
return $this->contact;
}
if($name == "billingaddress") {
$this->billingaddress = new Address($this->billingaddress_id);
$this->billingaddress = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->billingaddress_id);
if($this->billingaddress === null) {
$this->billingaddress = new Address($this->billingaddress_id);
if($this->billingaddress->id) {
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->billingaddress_id, $this->billingaddress);
}
}
return $this->billingaddress;
}
@@ -209,24 +216,51 @@ class Order extends mfBaseModel {
}
if($name == "creator") {
$this->creator = new User($this->create_by);
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($this->creator === null) {
$this->creator = new User($this->create_by);
if($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
}
}
return $this->creator;
}
if($name == "editor") {
$this->editor = new User($this->edit_by);
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
if($this->editor === null) {
$this->editor = new User($this->edit_by);
if($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
}
}
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$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;
}
/*$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}*/
}
return $this->$name;