1: <?php
2:
3: namespace Guzzle\Common;
4:
5: use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
6:
7: /**
8: * Default event for Guzzle notifications
9: */
10: class Event extends SymfonyEvent implements ToArrayInterface, \ArrayAccess, \IteratorAggregate
11: {
12: /**
13: * @var array
14: */
15: private $context;
16:
17: /**
18: * Constructor
19: *
20: * @param array $context Contextual information
21: */
22: public function __construct(array $context = array())
23: {
24: $this->context = $context;
25: }
26:
27: /**
28: * {@inheritdoc}
29: */
30: public function getIterator()
31: {
32: return new \ArrayIterator($this->context);
33: }
34:
35: /**
36: * {@inheritdoc}
37: */
38: public function offsetGet($offset)
39: {
40: return array_key_exists($offset, $this->context) ? $this->context[$offset] : null;
41: }
42:
43: /**
44: * {@inheritdoc}
45: */
46: public function offsetSet($offset, $value)
47: {
48: $this->context[$offset] = $value;
49: }
50:
51: /**
52: * {@inheritdoc}
53: */
54: public function offsetExists($offset)
55: {
56: return array_key_exists($offset, $this->context);
57: }
58:
59: /**
60: * {@inheritdoc}
61: */
62: public function offsetUnset($offset)
63: {
64: unset($this->context[$offset]);
65: }
66:
67: /**
68: * {@inheritdoc}
69: */
70: public function toArray()
71: {
72: return $this->context;
73: }
74: }
75: