You are here

public function Workflow::__construct in Workflow 7

CRUD functions.

File

includes/Entity/Workflow.php, line 24
Contains workflow\includes\Entity\Workflow.

Class

Workflow
@file Contains workflow\includes\Entity\Workflow.

Code

public function __construct($wid = 0) {
  if (!$wid) {

    // automatic constructor when casting an array or object.
    if (!is_array($this->options)) {
      $this->options = unserialize($this->options);
    }
    if ($this->wid) {
      self::$workflows[$this->wid] = $this;
    }
  }
  else {
    if (!isset(self::$workflows[$wid])) {
      self::$workflows[$wid] = Workflow::load($wid);
    }

    // Workflow may not exist.
    if (self::$workflows[$wid]) {

      // @todo: this copy-thing should not be necessary.
      $this->wid = self::$workflows[$wid]->wid;
      $this->name = self::$workflows[$wid]->name;
      $this->tab_roles = self::$workflows[$wid]->tab_roles;
      $this->options = self::$workflows[$wid]->options;
      $this->creation_sid = self::$workflows[$wid]->creation_sid;
    }
  }
}