Files
thetool/application/Workflowitem/Workflowitem.php
2022-09-06 19:09:42 +02:00

72 lines
2.1 KiB
PHP

<?php
class Workflowitem extends mfBaseModel {
private $value;
private $object_id;
public function setObjectId($object_id) {
if(!is_numeric($object_id)) {
return false;
}
$this->object_id = $object_id;
return true;
}
public function unsetObjectId() {
$this->object_id = null;
}
public function setValue(Workflowvalue $value) {
$this->value = $value;
}
public function getProperty($name) {
if($this->$name == null) {
if($name == "value") {
if(!$this->object_id) {
$this->log->warn(__CLASS__."::getProperty('value'): Object ID not set");
$this->log->debug("[Backtrace] ================");
$this->log->debug("[Backtrace] START Backtrace");
$bt = debug_backtrace();
foreach($bt as $n => $b) {
$this->log->debug($n.") ".$b["file"]."(".$b['line']."): ".$b['class']."->".$b['function']."()" );
}
$this->log->debug("[Backtrace] $sql");
$this->log->debug("[Backtrace] END Backtrace");
return null;
}
$value = mfValuecache::singleton()->get("wfItemvalue-item-".$this->id."-object-".$this->object_id);
if($this->id == 55 && $this->object_id == 509) {
var_dump($value);exit;
}
if($value) {
$this->value = $value;
return $value;
}
$value = WorkflowvalueModel::getFirst(['item_id' => $this->id, "object_id" => $this->object_id]);
// explicitly cache empty value
mfValuecache::singleton()->set("wfItemvalue-item-".$this->id."-object-".$this->object_id, $value);
if(!$value) {
$vdata['item_id'] = $this->id;
$vdata['object_id'] = $this->object_id;
$value = WorkflowvalueModel::create($vdata);
}
$this->value = $value;
return $this->value;
}
$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;
}
}