1 | <?php |
||
22 | class ModelBag |
||
23 | { |
||
24 | use NormalizeNamespaceTrait; |
||
25 | |||
26 | /** |
||
27 | * @var ModelInterface |
||
28 | */ |
||
29 | protected $collection = []; |
||
30 | |||
31 | /** |
||
32 | * @var ModelInterface |
||
33 | */ |
||
34 | protected $byAlias = []; |
||
35 | |||
36 | /** |
||
37 | * @var ModelInterface |
||
38 | */ |
||
39 | protected $byEntity = []; |
||
40 | |||
41 | /** |
||
42 | * Construct |
||
43 | * |
||
44 | * @param array $collection |
||
45 | */ |
||
46 | public function __construct($collection = []) |
||
50 | |||
51 | /** |
||
52 | * Retrieves offset value |
||
53 | * |
||
54 | * @param string $alias |
||
55 | * |
||
56 | * @return ModelInterface |
||
57 | * @throws ModelException |
||
58 | */ |
||
59 | public function get($alias) |
||
73 | |||
74 | /** |
||
75 | * Sets value to offset |
||
76 | * |
||
77 | * @param ModelInterface $model |
||
78 | * @param string $alias |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | public function set(ModelInterface $model, $alias = null) |
||
96 | |||
97 | /** |
||
98 | * Returns true if offset exists in bag |
||
99 | * |
||
100 | * @param string $alias |
||
101 | * |
||
102 | * @return bool |
||
103 | */ |
||
104 | public function has($alias) |
||
114 | |||
115 | /** |
||
116 | * Returns all options |
||
117 | * If array passed, becomes bag content |
||
118 | * |
||
119 | * @param array $array overwrites values |
||
120 | * |
||
121 | * @return ModelInterface[] |
||
122 | */ |
||
123 | public function all($array = []) |
||
133 | } |
||
134 |