1 | <?php |
||
14 | class Collection extends AbstractCollection |
||
|
|||
15 | { |
||
16 | protected $_indexKey = false; |
||
17 | |||
18 | /** |
||
19 | * @var Records |
||
20 | */ |
||
21 | protected $_manager = null; |
||
22 | |||
23 | |||
24 | /** |
||
25 | * @param $relations |
||
26 | */ |
||
27 | public function loadRelations($relations) |
||
37 | |||
38 | /** |
||
39 | * @param $name |
||
40 | * @return Collection |
||
41 | */ |
||
42 | public function loadRelation($name) |
||
49 | |||
50 | /** |
||
51 | * @param $name |
||
52 | * @return \Nip\Records\Relations\Relation|null |
||
53 | */ |
||
54 | public function getRelation($name) |
||
58 | |||
59 | /** |
||
60 | * @return Records |
||
61 | */ |
||
62 | 2 | public function getManager() |
|
63 | { |
||
64 | 2 | if ($this->_manager == null) { |
|
65 | 1 | $this->initManager(); |
|
66 | } |
||
67 | |||
68 | 2 | return $this->_manager; |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * @param Records $manager |
||
73 | * @return $this |
||
74 | */ |
||
75 | 2 | public function setManager(Records $manager) |
|
81 | |||
82 | 1 | public function initManager() |
|
83 | { |
||
84 | 1 | $manager = $this->rewind()->getManager(); |
|
85 | 1 | $this->setManager($manager); |
|
86 | 1 | } |
|
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | */ |
||
91 | public function toJSON() |
||
100 | |||
101 | public function save() |
||
109 | |||
110 | /** |
||
111 | * @param Record $record |
||
112 | * @param string $index |
||
113 | */ |
||
114 | 3 | public function add($record, $index = null) |
|
115 | { |
||
116 | 3 | $index = $this->getRecordKey($record, $index); |
|
117 | 3 | parent::add($record, $index); |
|
118 | 3 | } |
|
119 | |||
120 | /** |
||
121 | * @param Record $record |
||
122 | * @param null $index |
||
123 | * @return bool|mixed|null |
||
124 | */ |
||
125 | 3 | public function getRecordKey(Record $record, $index = null) |
|
126 | { |
||
127 | 3 | if ($index) { |
|
128 | $index = $record->{$index}; |
||
129 | } else { |
||
130 | 3 | $index = $this->getIndexKey(); |
|
131 | 3 | $index = $index ? $record->{$index} : $record->getPrimaryKey(); |
|
132 | 3 | if (!$index) { |
|
133 | 2 | $index = null; |
|
134 | } |
||
135 | } |
||
136 | 3 | return $index; |
|
137 | } |
||
138 | |||
139 | /** |
||
140 | * @return bool |
||
141 | */ |
||
142 | 3 | public function getIndexKey() |
|
143 | { |
||
144 | 3 | return $this->_indexKey; |
|
145 | } |
||
146 | |||
147 | /** |
||
148 | * @param $key |
||
149 | * @return mixed |
||
150 | */ |
||
151 | public function setIndexKey($key) |
||
155 | |||
156 | /** |
||
157 | * @param Record $record |
||
158 | * @return bool |
||
159 | */ |
||
160 | public function has($record) |
||
168 | |||
169 | /** |
||
170 | * @param Record $record |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function hasRecord(Record $record) |
||
179 | |||
180 | /** |
||
181 | * @param $record |
||
182 | */ |
||
183 | public function remove($record) |
||
191 | |||
192 | /** |
||
193 | * When $each is true, each record gets it's delete() method called. |
||
194 | * Otherwise, a delete query is built for the entire collection |
||
195 | * |
||
196 | * @param bool $each |
||
197 | * @return $this |
||
198 | */ |
||
199 | public function delete($each = false) |
||
220 | } |
||
221 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.