MDL-25505 Tasks: Fix for scheduled task bug on the last day of the month.
[moodle.git] / lib / classes / event / base.php
CommitLineData
d8a1f426
PS
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17namespace core\event;
18
5999e40f
MN
19defined('MOODLE_INTERNAL') || die();
20
d8a1f426
PS
21/**
22 * Base event class.
23 *
24 * @package core
25 * @copyright 2013 Petr Skoda {@link http://skodak.org}
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 */
28
d8a1f426
PS
29/**
30 * All other event classes must extend this class.
31 *
32 * @package core
33 * @copyright 2013 Petr Skoda {@link http://skodak.org}
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 *
36 * @property-read string $eventname Name of the event (=== class name with leading \)
37 * @property-read string $component Full frankenstyle component name
38 * @property-read string $action what happened
660f049f 39 * @property-read string $target what/who was target of the action
a85258ca 40 * @property-read string $objecttable name of database table where is object record stored
d8a1f426
PS
41 * @property-read int $objectid optional id of the object
42 * @property-read string $crud letter indicating event type
3345e24f 43 * @property-read int $edulevel log level (one of the constants LEVEL_)
d8a1f426
PS
44 * @property-read int $contextid
45 * @property-read int $contextlevel
46 * @property-read int $contextinstanceid
47 * @property-read int $userid who did this?
48 * @property-read int $courseid
49 * @property-read int $relateduserid
c4297815 50 * @property-read mixed $other array or scalar, can not contain objects
d8a1f426
PS
51 * @property-read int $timecreated
52 */
ed17808d 53abstract class base implements \IteratorAggregate {
38d6fbfa
FM
54
55 /**
56 * Other level.
57 */
58 const LEVEL_OTHER = 0;
59
60 /**
61 * Teaching level.
62 *
63 * Any event that is performed by someone (typically a teacher) and has a teaching value,
64 * anything that is affecting the learning experience/environment of the students.
65 */
66 const LEVEL_TEACHING = 1;
67
68 /**
69 * Participating level.
70 *
71 * Any event that is performed by a user, and is related (or could be related) to his learning experience.
72 */
73 const LEVEL_PARTICIPATING = 2;
74
d8a1f426
PS
75 /** @var array event data */
76 protected $data;
77
4b734e74 78 /** @var array the format is standardised by logging API */
b0cdc969 79 protected $logextra;
4b734e74 80
d8a1f426
PS
81 /** @var \context of this event */
82 protected $context;
83
22626564
PS
84 /**
85 * @var bool indicates if event was already triggered,
86 * this prevents second attempt to trigger event.
87 */
d8a1f426
PS
88 private $triggered;
89
22626564
PS
90 /**
91 * @var bool indicates if event was already dispatched,
92 * this prevents direct calling of manager::dispatch($event).
93 */
94 private $dispatched;
95
96 /**
97 * @var bool indicates if event was restored from storage,
98 * this prevents triggering of restored events.
99 */
d8a1f426
PS
100 private $restored;
101
102 /** @var array list of event properties */
103 private static $fields = array(
3345e24f 104 'eventname', 'component', 'action', 'target', 'objecttable', 'objectid', 'crud', 'edulevel', 'contextid',
c4297815 105 'contextlevel', 'contextinstanceid', 'userid', 'courseid', 'relateduserid', 'other',
4b734e74 106 'timecreated');
d8a1f426
PS
107
108 /** @var array simple record cache */
fd4f3e9e 109 private $recordsnapshots = array();
d8a1f426
PS
110
111 /**
112 * Private constructor, use create() or restore() methods instead.
113 */
114 private final function __construct() {
115 $this->data = array_fill_keys(self::$fields, null);
b6c7ab22
AA
116
117 // Define some basic details.
118 $classname = get_called_class();
119 $parts = explode('\\', $classname);
120 if (count($parts) !== 3 or $parts[1] !== 'event') {
121 throw new \coding_exception("Invalid event class name '$classname', it must be defined in component\\event\\
122 namespace");
123 }
124 $this->data['eventname'] = '\\'.$classname;
125 $this->data['component'] = $parts[0];
126
127 $pos = strrpos($parts[2], '_');
128 if ($pos === false) {
129 throw new \coding_exception("Invalid event class name '$classname', there must be at least one underscore separating
130 object and action words");
131 }
132 $this->data['target'] = substr($parts[2], 0, $pos);
133 $this->data['action'] = substr($parts[2], $pos + 1);
d8a1f426
PS
134 }
135
136 /**
137 * Create new event.
138 *
139 * The optional data keys as:
140 * 1/ objectid - the id of the object specified in class name
141 * 2/ context - the context of this event
c4297815 142 * 3/ other - the other data describing the event, can not contain objects
d8a1f426
PS
143 * 4/ relateduserid - the id of user which is somehow related to this event
144 *
145 * @param array $data
146 * @return \core\event\base returns instance of new event
147 *
148 * @throws \coding_exception
149 */
150 public static final function create(array $data = null) {
3345e24f 151 global $USER, $CFG;
d8a1f426
PS
152
153 $data = (array)$data;
154
155 /** @var \core\event\base $event */
156 $event = new static();
157 $event->triggered = false;
158 $event->restored = false;
22626564 159 $event->dispatched = false;
d8a1f426 160
fb23739e
PS
161 // Set static event data specific for child class.
162 $event->init();
163
3345e24f
164 if (isset($event->data['level'])) {
165 if (!isset($event->data['edulevel'])) {
166 debugging('level property is deprecated, use edulevel property instead', DEBUG_DEVELOPER);
167 $event->data['edulevel'] = $event->data['level'];
168 }
169 unset($event->data['level']);
170 }
171
4b734e74
PS
172 // Set automatic data.
173 $event->data['timecreated'] = time();
174
4b734e74 175 // Set optional data or use defaults.
d8a1f426
PS
176 $event->data['objectid'] = isset($data['objectid']) ? $data['objectid'] : null;
177 $event->data['courseid'] = isset($data['courseid']) ? $data['courseid'] : null;
178 $event->data['userid'] = isset($data['userid']) ? $data['userid'] : $USER->id;
c4297815 179 $event->data['other'] = isset($data['other']) ? $data['other'] : null;
d8a1f426
PS
180 $event->data['relateduserid'] = isset($data['relateduserid']) ? $data['relateduserid'] : null;
181
fddd1018 182 if (isset($event->context)) {
097011c4
PS
183 if (isset($data['context'])) {
184 debugging('Context was already set in init() method, ignoring context parameter', DEBUG_DEVELOPER);
fddd1018 185 }
fddd1018
PS
186
187 } else if (!empty($data['context'])) {
d8a1f426 188 $event->context = $data['context'];
27af3e62
PS
189
190 } else if (!empty($data['contextid'])) {
097011c4
PS
191 $event->context = \context::instance_by_id($data['contextid'], MUST_EXIST);
192
27af3e62 193 } else {
fddd1018 194 throw new \coding_exception('context (or contextid) is a required event property, system context may be hardcoded in init() method.');
d8a1f426 195 }
d8a1f426 196
097011c4
PS
197 $event->data['contextid'] = $event->context->id;
198 $event->data['contextlevel'] = $event->context->contextlevel;
199 $event->data['contextinstanceid'] = $event->context->instanceid;
200
d8a1f426 201 if (!isset($event->data['courseid'])) {
097011c4 202 if ($coursecontext = $event->context->get_course_context(false)) {
513d8793 203 $event->data['courseid'] = $coursecontext->instanceid;
d8a1f426
PS
204 } else {
205 $event->data['courseid'] = 0;
206 }
207 }
208
097011c4 209 if (!array_key_exists('relateduserid', $data) and $event->context->contextlevel == CONTEXT_USER) {
d8a1f426
PS
210 $event->data['relateduserid'] = $event->context->instanceid;
211 }
212
4b734e74 213 // Warn developers if they do something wrong.
96f81ea3 214 if ($CFG->debugdeveloper) {
660f049f 215 static $automatickeys = array('eventname', 'component', 'action', 'target', 'contextlevel', 'contextinstanceid', 'timecreated');
3345e24f 216 static $initkeys = array('crud', 'level', 'objecttable', 'edulevel');
4b734e74
PS
217
218 foreach ($data as $key => $ignored) {
219 if ($key === 'context') {
220 continue;
221
222 } else if (in_array($key, $automatickeys)) {
96f81ea3 223 debugging("Data key '$key' is not allowed in \\core\\event\\base::create() method, it is set automatically", DEBUG_DEVELOPER);
4b734e74
PS
224
225 } else if (in_array($key, $initkeys)) {
96f81ea3 226 debugging("Data key '$key' is not allowed in \\core\\event\\base::create() method, you need to set it in init() method", DEBUG_DEVELOPER);
4b734e74
PS
227
228 } else if (!in_array($key, self::$fields)) {
229 debugging("Data key '$key' does not exist in \\core\\event\\base");
d8a1f426
PS
230 }
231 }
232 }
233
c61a3a5c 234 // Let developers validate their custom data (such as $this->data['other'], contextlevel, etc.).
fddd1018
PS
235 $event->validate_data();
236
d8a1f426
PS
237 return $event;
238 }
239
240 /**
241 * Override in subclass.
242 *
243 * Set all required data properties:
38d6fbfa 244 * 1/ crud - letter [crud]
3345e24f 245 * 2/ edulevel - using a constant self::LEVEL_*.
a85258ca 246 * 3/ objecttable - name of database table if objectid specified
4b734e74 247 *
fddd1018
PS
248 * Optionally it can set:
249 * a/ fixed system context
d8a1f426
PS
250 *
251 * @return void
252 */
253 protected abstract function init();
254
fddd1018 255 /**
c61a3a5c 256 * Let developers validate their custom data (such as $this->data['other'], contextlevel, etc.).
fddd1018
PS
257 *
258 * Throw \coding_exception or debugging() notice in case of any problems.
259 */
260 protected function validate_data() {
261 // Override if you want to validate event properties when
262 // creating new events.
263 }
264
4b734e74
PS
265 /**
266 * Returns localised general event name.
267 *
268 * Override in subclass, we can not make it static and abstract at the same time.
269 *
fc9fc9fb 270 * @return string
4b734e74
PS
271 */
272 public static function get_name() {
273 // Override in subclass with real lang string.
1ccc1268 274 $parts = explode('\\', get_called_class());
4b734e74 275 if (count($parts) !== 3) {
fc9fc9fb 276 return get_string('unknownevent', 'error');
4b734e74
PS
277 }
278 return $parts[0].': '.str_replace('_', ' ', $parts[2]);
279 }
280
281 /**
fc9fc9fb 282 * Returns non-localised event description with id's for admin use only.
05a970d3 283 *
fc9fc9fb 284 * @return string
4b734e74
PS
285 */
286 public function get_description() {
287 return null;
288 }
289
290 /**
291 * Define whether a user can view the event or not.
292 *
293 * @param int|\stdClass $user_or_id ID of the user.
294 * @return bool True if the user can view the event, false otherwise.
295 */
296 public function can_view($user_or_id = null) {
297 return is_siteadmin($user_or_id);
298 }
299
d8a1f426
PS
300 /**
301 * Restore event from existing historic data.
302 *
303 * @param array $data
b0cdc969 304 * @param array $logextra the format is standardised by logging API
d8a1f426
PS
305 * @return bool|\core\event\base
306 */
b0cdc969 307 public static final function restore(array $data, array $logextra) {
d8a1f426
PS
308 $classname = $data['eventname'];
309 $component = $data['component'];
310 $action = $data['action'];
132eff90 311 $target = $data['target'];
d8a1f426
PS
312
313 // Security: make 100% sure this really is an event class.
132eff90 314 if ($classname !== "\\{$component}\\event\\{$target}_{$action}") {
d8a1f426
PS
315 return false;
316 }
317
318 if (!class_exists($classname)) {
319 return false;
320 }
321 $event = new $classname();
322 if (!($event instanceof \core\event\base)) {
323 return false;
324 }
325
d8a1f426 326 $event->restored = true;
22626564
PS
327 $event->triggered = true;
328 $event->dispatched = true;
b0cdc969 329 $event->logextra = $logextra;
d8a1f426
PS
330
331 foreach (self::$fields as $key) {
4b734e74 332 if (!array_key_exists($key, $data)) {
d8a1f426 333 debugging("Event restore data must contain key $key");
4b734e74 334 $data[$key] = null;
d8a1f426
PS
335 }
336 }
4b734e74
PS
337 if (count($data) != count(self::$fields)) {
338 foreach ($data as $key => $value) {
339 if (!in_array($key, self::$fields)) {
340 debugging("Event restore data cannot contain key $key");
341 unset($data[$key]);
342 }
343 }
344 }
345 $event->data = $data;
d8a1f426
PS
346
347 return $event;
348 }
349
d8a1f426
PS
350 /**
351 * Returns event context.
352 * @return \context
353 */
354 public function get_context() {
355 if (isset($this->context)) {
356 return $this->context;
357 }
fdc729ea 358 $this->context = \context::instance_by_id($this->data['contextid'], IGNORE_MISSING);
d8a1f426
PS
359 return $this->context;
360 }
361
362 /**
363 * Returns relevant URL, override in subclasses.
4b734e74 364 * @return \moodle_url
d8a1f426
PS
365 */
366 public function get_url() {
367 return null;
368 }
369
370 /**
371 * Return standardised event data as array.
372 *
3345e24f 373 * @return array All elements are scalars except the 'other' field which is array.
d8a1f426
PS
374 */
375 public function get_data() {
376 return $this->data;
377 }
378
4b734e74
PS
379 /**
380 * Return auxiliary data that was stored in logs.
381 *
3345e24f
382 * List of standard properties:
383 * - origin: IP number, cli,cron
384 * - realuserid: id of the user when logged-in-as
05a970d3 385 *
4b734e74
PS
386 * @return array the format is standardised by logging API
387 */
b0cdc969
PS
388 public function get_logextra() {
389 return $this->logextra;
4b734e74
PS
390 }
391
d8a1f426
PS
392 /**
393 * Does this event replace legacy event?
394 *
82b1fb51
PS
395 * Note: do not use directly!
396 *
d8a1f426
PS
397 * @return null|string legacy event name
398 */
22446003 399 public static function get_legacy_eventname() {
d8a1f426
PS
400 return null;
401 }
402
403 /**
404 * Legacy event data if get_legacy_eventname() is not empty.
405 *
82b1fb51
PS
406 * Note: do not use directly!
407 *
d8a1f426
PS
408 * @return mixed
409 */
82b1fb51 410 protected function get_legacy_eventdata() {
d8a1f426
PS
411 return null;
412 }
413
414 /**
415 * Doest this event replace add_to_log() statement?
416 *
82b1fb51
PS
417 * Note: do not use directly!
418 *
d8a1f426
PS
419 * @return null|array of parameters to be passed to legacy add_to_log() function.
420 */
82b1fb51 421 protected function get_legacy_logdata() {
d8a1f426
PS
422 return null;
423 }
424
425 /**
426 * Validate all properties right before triggering the event.
427 *
428 * This throws coding exceptions for fatal problems and debugging for minor problems.
429 *
430 * @throws \coding_exception
431 */
432 protected final function validate_before_trigger() {
96f81ea3 433 global $DB, $CFG;
a85258ca 434
d8a1f426
PS
435 if (empty($this->data['crud'])) {
436 throw new \coding_exception('crud must be specified in init() method of each method');
437 }
3345e24f
438 if (!isset($this->data['edulevel'])) {
439 throw new \coding_exception('edulevel must be specified in init() method of each method');
d8a1f426 440 }
a85258ca
PS
441 if (!empty($this->data['objectid']) and empty($this->data['objecttable'])) {
442 throw new \coding_exception('objecttable must be specified in init() method if objectid present');
443 }
d8a1f426 444
96f81ea3 445 if ($CFG->debugdeveloper) {
d8a1f426
PS
446 // Ideally these should be coding exceptions, but we need to skip these for performance reasons
447 // on production servers.
4b734e74
PS
448
449 if (!in_array($this->data['crud'], array('c', 'r', 'u', 'd'), true)) {
96f81ea3 450 debugging("Invalid event crud value specified.", DEBUG_DEVELOPER);
4b734e74 451 }
3345e24f 452 if (!in_array($this->data['edulevel'], array(self::LEVEL_OTHER, self::LEVEL_TEACHING, self::LEVEL_PARTICIPATING))) {
38d6fbfa 453 // Bitwise combination of levels is not allowed at this stage.
3345e24f 454 debugging('Event property edulevel must a constant value, see event_base::LEVEL_*', DEBUG_DEVELOPER);
4b734e74 455 }
d8a1f426 456 if (self::$fields !== array_keys($this->data)) {
96f81ea3 457 debugging('Number of event data fields must not be changed in event classes', DEBUG_DEVELOPER);
d8a1f426 458 }
c4297815 459 $encoded = json_encode($this->data['other']);
49ff1342
AG
460 // The comparison here is not set to strict as whole float numbers will be converted to integers through JSON encoding /
461 // decoding and send an unwanted debugging message.
462 if ($encoded === false or $this->data['other'] != json_decode($encoded, true)) {
96f81ea3 463 debugging('other event data must be compatible with json encoding', DEBUG_DEVELOPER);
4b734e74
PS
464 }
465 if ($this->data['userid'] and !is_number($this->data['userid'])) {
96f81ea3 466 debugging('Event property userid must be a number', DEBUG_DEVELOPER);
4b734e74
PS
467 }
468 if ($this->data['courseid'] and !is_number($this->data['courseid'])) {
96f81ea3 469 debugging('Event property courseid must be a number', DEBUG_DEVELOPER);
4b734e74
PS
470 }
471 if ($this->data['objectid'] and !is_number($this->data['objectid'])) {
96f81ea3 472 debugging('Event property objectid must be a number', DEBUG_DEVELOPER);
4b734e74
PS
473 }
474 if ($this->data['relateduserid'] and !is_number($this->data['relateduserid'])) {
96f81ea3 475 debugging('Event property relateduserid must be a number', DEBUG_DEVELOPER);
d8a1f426 476 }
a85258ca
PS
477 if ($this->data['objecttable']) {
478 if (!$DB->get_manager()->table_exists($this->data['objecttable'])) {
96f81ea3 479 debugging('Unknown table specified in objecttable field', DEBUG_DEVELOPER);
a85258ca 480 }
31e571cd
FM
481 if (!isset($this->data['objectid'])) {
482 debugging('Event property objectid must be set when objecttable is defined', DEBUG_DEVELOPER);
483 }
a85258ca 484 }
d8a1f426
PS
485 }
486 }
487
488 /**
489 * Trigger event.
490 */
491 public final function trigger() {
492 global $CFG;
493
494 if ($this->restored) {
495 throw new \coding_exception('Can not trigger restored event');
496 }
22626564 497 if ($this->triggered or $this->dispatched) {
d8a1f426
PS
498 throw new \coding_exception('Can not trigger event twice');
499 }
500
d8a1f426
PS
501 $this->validate_before_trigger();
502
22626564
PS
503 $this->triggered = true;
504
ef1987dc 505 if (isset($CFG->loglifetime) and $CFG->loglifetime != -1) {
d8a1f426
PS
506 if ($data = $this->get_legacy_logdata()) {
507 call_user_func_array('add_to_log', $data);
508 }
509 }
510
62401e8f
PS
511 if (PHPUNIT_TEST and \phpunit_util::is_redirecting_events()) {
512 $this->dispatched = true;
513 \phpunit_util::event_triggered($this);
514 return;
515 }
516
d8a1f426
PS
517 \core\event\manager::dispatch($this);
518
22626564
PS
519 $this->dispatched = true;
520
22446003 521 if ($legacyeventname = static::get_legacy_eventname()) {
f0f0e1fe 522 events_trigger_legacy($legacyeventname, $this->get_legacy_eventdata());
d8a1f426
PS
523 }
524 }
525
526 /**
22626564 527 * Was this event already triggered?
d8a1f426
PS
528 *
529 * @return bool
530 */
22626564 531 public final function is_triggered() {
d8a1f426
PS
532 return $this->triggered;
533 }
534
22626564
PS
535 /**
536 * Used from event manager to prevent direct access.
537 *
538 * @return bool
539 */
540 public final function is_dispatched() {
541 return $this->dispatched;
542 }
543
d8a1f426 544 /**
4b734e74 545 * Was this event restored?
d8a1f426
PS
546 *
547 * @return bool
548 */
22626564 549 public final function is_restored() {
d8a1f426
PS
550 return $this->restored;
551 }
552
553 /**
554 * Add cached data that will be most probably used in event observers.
555 *
556 * This is used to improve performance, but it is required for data
4b734e74 557 * that was just deleted.
d8a1f426
PS
558 *
559 * @param string $tablename
560 * @param \stdClass $record
300dbc66
PS
561 *
562 * @throws \coding_exception if used after ::trigger()
d8a1f426 563 */
fd4f3e9e 564 public final function add_record_snapshot($tablename, $record) {
96f81ea3 565 global $DB, $CFG;
d8a1f426 566
300dbc66
PS
567 if ($this->triggered) {
568 throw new \coding_exception('It is not possible to add snapshots after triggering of events');
569 }
570
d8a1f426
PS
571 // NOTE: this might use some kind of MUC cache,
572 // hopefully we will not run out of memory here...
96f81ea3 573 if ($CFG->debugdeveloper) {
d8a1f426 574 if (!$DB->get_manager()->table_exists($tablename)) {
96f81ea3 575 debugging("Invalid table name '$tablename' specified, database table does not exist.", DEBUG_DEVELOPER);
d8a1f426
PS
576 }
577 }
b396d40e 578 $this->recordsnapshots[$tablename][$record->id] = $record;
d8a1f426
PS
579 }
580
581 /**
582 * Returns cached record or fetches data from database if not cached.
583 *
584 * @param string $tablename
585 * @param int $id
586 * @return \stdClass
4ad6d5c5
PS
587 *
588 * @throws \coding_exception if used after ::restore()
d8a1f426 589 */
fd4f3e9e 590 public final function get_record_snapshot($tablename, $id) {
d8a1f426
PS
591 global $DB;
592
4ad6d5c5
PS
593 if ($this->restored) {
594 throw new \coding_exception('It is not possible to get snapshots from restored events');
595 }
596
b396d40e
PS
597 if (isset($this->recordsnapshots[$tablename][$id])) {
598 return $this->recordsnapshots[$tablename][$id];
d8a1f426
PS
599 }
600
601 $record = $DB->get_record($tablename, array('id'=>$id));
b396d40e 602 $this->recordsnapshots[$tablename][$id] = $record;
d8a1f426
PS
603
604 return $record;
605 }
606
607 /**
608 * Magic getter for read only access.
609 *
d8a1f426
PS
610 * @param string $name
611 * @return mixed
d8a1f426
PS
612 */
613 public function __get($name) {
3345e24f
614 if ($name === 'level') {
615 debugging('level property is deprecated, use edulevel property instead', DEBUG_DEVELOPER);
616 return $this->data['edulevel'];
617 }
d8a1f426
PS
618 if (array_key_exists($name, $this->data)) {
619 return $this->data[$name];
620 }
621
4b734e74 622 debugging("Accessing non-existent event property '$name'");
d8a1f426 623 }
605a8c33
PS
624
625 /**
626 * Magic setter.
627 *
628 * Note: we must not allow modification of data from outside,
629 * after trigger() the data MUST NOT CHANGE!!!
630 *
631 * @param string $name
632 * @param mixed $value
633 *
634 * @throws \coding_exception
635 */
636 public function __set($name, $value) {
637 throw new \coding_exception('Event properties must not be modified.');
638 }
639
640 /**
641 * Is data property set?
642 *
643 * @param string $name
644 * @return bool
645 */
646 public function __isset($name) {
3345e24f
647 if ($name === 'level') {
648 debugging('level property is deprecated, use edulevel property instead', DEBUG_DEVELOPER);
649 return isset($this->data['edulevel']);
650 }
605a8c33
PS
651 return isset($this->data[$name]);
652 }
ed17808d
PS
653
654 /**
655 * Create an iterator because magic vars can't be seen by 'foreach'.
656 *
657 * @return \ArrayIterator
658 */
659 public function getIterator() {
660 return new \ArrayIterator($this->data);
661 }
d8a1f426 662}