loadMe(); $data["edit_by"] = $me->id; } return $data; } public function getProperty($name) { if($this->$name == null) { if(!$this->id) { return null; } if($name == "products") { $this->products = mfValuecache::singleton()->get("Productgroup-id-".$this->id."-Products"); if($this->products === null) { $this->products = ProductModel::search(['productgroup_id' => $this->id]); if($this->products) { mfValuecache::singleton()->set("Productgroup-id-".$this->id."-Products", $this->products); } } return $this->products; } if($name == "contractconfiggroups") { $this->contractconfiggroups = mfValuecache::singleton()->get("Contractconfiggroups-byProductgroupid-".$this->id); if($this->contractconfiggroups === null) { $this->contractconfiggroups = []; foreach(ContractconfiggroupProductgroupModel::search(['productgroup_id' => $this->id]) as $ccpg) { $this->contractconfiggroups[$ccpg->contractconfiggroup_id] = $ccpg->contractconfiggroup; } if(count($this->contractconfiggroups)) { mfValuecache::singleton()->set("Contractconfiggroups-byProductgroupid-".$this->id, $this->contractconfiggroups); } } return $this->contractconfiggroups; } if($name == "creator") { $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 = 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; } } return $this->$name; } }