WIP commit for API board model
This commit is contained in:
parent
cbcf132955
commit
13853c6d9e
@ -15,7 +15,7 @@ class Activity extends BaseModel {
|
||||
|
||||
public static function fromBean($container, $bean) {
|
||||
$instance = new self($container, 0);
|
||||
$instance->loadFromBean($bean);
|
||||
$instance->loadFromBean($container, $bean);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -23,7 +23,7 @@ class Activity extends BaseModel {
|
||||
public function updateBean() {
|
||||
}
|
||||
|
||||
public function loadFromBean($bean) {
|
||||
public function loadFromBean($container, $bean) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ abstract class BaseModel {
|
||||
}
|
||||
|
||||
public abstract function updateBean();
|
||||
public abstract function loadFromBean($bean);
|
||||
public abstract function loadFromBean($container, $bean);
|
||||
|
||||
public function save() {
|
||||
$this->updateBean();
|
||||
|
@ -4,6 +4,9 @@ class Board extends BaseModel {
|
||||
public $name = '';
|
||||
public $is_active = true;
|
||||
public $columns = [];
|
||||
public $categories = [];
|
||||
public $auto_actions = [];
|
||||
public $users = [];
|
||||
|
||||
public function __construct($container, $id = 0, $internal = false) {
|
||||
parent::__construct('board', $id, $container);
|
||||
@ -12,19 +15,19 @@ class Board extends BaseModel {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->loadFromBean($this->bean);
|
||||
$this->loadFromBean($container, $this->bean);
|
||||
}
|
||||
|
||||
public static function fromBean($container, $bean) {
|
||||
$instance = new self($container, 0, true);
|
||||
$instance->loadFromBean($bean);
|
||||
$instance->loadFromBean($container, $bean);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public static function fromJson($container, $json) {
|
||||
$instance = new self($container, 0, true);
|
||||
$instance->loadFromJson($json);
|
||||
$instance->loadFromJson($container, $json);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -32,10 +35,40 @@ class Board extends BaseModel {
|
||||
public function updateBean() {
|
||||
}
|
||||
|
||||
public function loadFromBean($bean) {
|
||||
public function loadFromBean($container, $bean) {
|
||||
if (!isset($bean->id) || $bean->id === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->id = $bean->id;
|
||||
$this->name = $bean->name;
|
||||
$this->is_active = $bean->is_active;
|
||||
|
||||
$this->updateBean();
|
||||
}
|
||||
|
||||
public function loadFromJson($json) {
|
||||
// TODO: Determine if all models should have loadFromJson method
|
||||
public function loadFromJson($container, $json) {
|
||||
$obj = json_decode($json);
|
||||
|
||||
if (!isset($obj->id) || $obj->id === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->id = $obj->id;
|
||||
$this->name = $obj->name;
|
||||
$this->is_active = $obj->is_active;
|
||||
|
||||
foreach($obj->columns as $col) {
|
||||
if ($col->id) {
|
||||
$this->columns[] = new Column($container, $col->id);
|
||||
} else {
|
||||
// TODO: Determine if all models should have fromObject method
|
||||
$this->columns[] = Column::fromObject($col);
|
||||
}
|
||||
}
|
||||
|
||||
$this->updateBean();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user