/
Store.php
59 lines (46 loc) · 1.16 KB
/
Store.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Northstyle\Module\Shop\DataObject;
use Northstyle\Common\DataObject;
use Northstyle\Module\Core\DataObject\Id;
class Store extends DataObject {
public $id = null;
public $label = '';
public $attribute_sets = array();
public $views = array();
public function _init($data = array()) {
if (!isset($data['id'])) {
$this->set_id(0);
}
}
public function set_id($value) {
if (is_object($value) && $value instanceof Id) {
$this->id = $value;
} else {
$this->id = Id::create($value);
}
}
public function set_attribute_sets($value) {
if (is_array($value)) {
$this->attribute_sets = array();
foreach ($value as $item) {
if (is_object($item) && $item instanceof AttributeSet) {
$this->attribute_sets[] = $item;
} else if (is_array($item)) {
$this->attribute_sets[] = new AttributeSet($item);
}
}
}
}
public function set_views($value) {
if (is_array($value)) {
$this->views = array();
foreach ($value as $item) {
if (is_object($item) && $item instanceof StoreView) {
$this->views[] = $item;
} else if (is_array($item)) {
$this->views[] = new StoreView($item);
}
}
}
}
}