public function WorkflowState::__construct in Workflow 7
Same name and namespace in other branches
- 7.2 includes/Entity/WorkflowState.php \WorkflowState::__construct()
CRUD functions.
File
- includes/
Entity/ WorkflowState.php, line 24 - Contains workflow\includes\Entity\WorkflowState.
Class
- WorkflowState
- @file Contains workflow\includes\Entity\WorkflowState.
Code
public function __construct($sid = 0, $wid = 0) {
if (empty($sid) && empty($wid)) {
// automatic constructor when casting an array or object.
if (!isset(self::$states[$this->sid])) {
self::$states[$this->sid] = $this;
}
}
elseif (empty($sid)) {
// Creating an dummy/new state for a workflow.
// Do not add to 'cache' self::$tates.
$this->wid = $wid;
}
else {
// Fetching an existing state for a workflow.
if (!isset(self::$states[$sid])) {
self::$states[$sid] = WorkflowState::load($sid, $wid);
}
// State may not exist.
if (self::$states[$sid]) {
// @todo: this copy-thing should not be necessary.
$this->sid = self::$states[$sid]->sid;
$this->wid = self::$states[$sid]->wid;
$this->weight = self::$states[$sid]->weight;
$this->sysid = self::$states[$sid]->sysid;
$this->state = self::$states[$sid]->state;
$this->status = self::$states[$sid]->status;
$this->workflow = self::$states[$sid]->workflow;
}
}
}