1 | <?php |
||
14 | abstract class AbstractReader implements ReaderInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var ResourceCollection |
||
18 | */ |
||
19 | protected $resources; |
||
20 | |||
21 | /** |
||
22 | * @var ResourceInterface |
||
23 | */ |
||
24 | protected $resource; |
||
25 | |||
26 | /** |
||
27 | * @var EventDispatcherInterface |
||
28 | */ |
||
29 | protected $eventDispatcher; |
||
30 | |||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | protected $initialized; |
||
35 | |||
36 | /** |
||
37 | * @param mixed $resources Optional resource collection. Can be a Resource, an array of |
||
38 | * Resource's, or a ResourceCollection. When empty, a new collection |
||
39 | * will be created. |
||
40 | * @param EventDispatcherInterface $dispatcher Optional event dispatcher. |
||
41 | * |
||
42 | * @throws \InvalidArgumentException |
||
43 | */ |
||
44 | 74 | public function __construct($resources = null, EventDispatcherInterface $dispatcher = null) |
|
67 | |||
68 | /** |
||
69 | * @inheritdoc |
||
70 | */ |
||
71 | 48 | public function current() |
|
77 | |||
78 | /** |
||
79 | * @inheritdoc |
||
80 | */ |
||
81 | public function key() |
||
87 | |||
88 | /** |
||
89 | * @inheritdoc |
||
90 | */ |
||
91 | 52 | public function next() |
|
102 | |||
103 | /** |
||
104 | * @inheritdoc |
||
105 | */ |
||
106 | public function rewind() |
||
112 | |||
113 | /** |
||
114 | * @inheritdoc |
||
115 | */ |
||
116 | 48 | public function valid() |
|
122 | |||
123 | /** |
||
124 | * Wrapper that implements various calls, so you can use the iterator in a |
||
125 | * simple while loop. |
||
126 | * |
||
127 | * @return ParameterBag |
||
128 | */ |
||
129 | 46 | public function read() |
|
149 | |||
150 | /** |
||
151 | * @inheritdoc |
||
152 | */ |
||
153 | 2 | public function setResources(ResourceCollection $resources) |
|
160 | |||
161 | /** |
||
162 | * @inheritdoc |
||
163 | */ |
||
164 | public function getResources() |
||
168 | |||
169 | /** |
||
170 | * @return ResourceInterface |
||
171 | */ |
||
172 | public function getCurrentResource() |
||
176 | |||
177 | /** |
||
178 | * @return EventDispatcherInterface |
||
179 | */ |
||
180 | public function getEventDispatcher() |
||
184 | |||
185 | /** |
||
186 | * |
||
187 | */ |
||
188 | 52 | protected function createNextReader() |
|
214 | |||
215 | /** |
||
216 | * |
||
217 | */ |
||
218 | 52 | protected function initialize() |
|
230 | |||
231 | /** |
||
232 | * Serializes a read item into a ParameterBag. |
||
233 | * |
||
234 | * @param string $data |
||
235 | * |
||
236 | * @return ParameterBag |
||
237 | */ |
||
238 | abstract protected function serialize($data); |
||
239 | |||
240 | /** |
||
241 | * Creates a reader for a resource. |
||
242 | * |
||
243 | * @param ResourceInterface $resource |
||
244 | */ |
||
245 | abstract protected function createReader(ResourceInterface $resource); |
||
246 | |||
247 | /** |
||
248 | * @see \Iterator::key() |
||
249 | */ |
||
250 | abstract protected function doKey(); |
||
251 | |||
252 | /** |
||
253 | * @see \Iterator::current() |
||
254 | */ |
||
255 | abstract protected function doCurrent(); |
||
256 | |||
257 | /** |
||
258 | * @see \Iterator::next() |
||
259 | */ |
||
260 | abstract protected function doNext(); |
||
261 | |||
262 | /** |
||
263 | * @see \Iterator::valid() |
||
264 | */ |
||
265 | abstract protected function doValid(); |
||
266 | |||
267 | /** |
||
268 | * @see \Iterator::rewind() |
||
269 | */ |
||
270 | abstract protected function doRewind(); |
||
271 | } |
||
272 |