123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <?php
- namespace Symfony\Component\EventDispatcher;
- use Symfony\Contracts\EventDispatcher\Event;
- class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
- {
- protected $subject;
- protected $arguments;
-
- public function __construct($subject = null, array $arguments = [])
- {
- $this->subject = $subject;
- $this->arguments = $arguments;
- }
-
- public function getSubject()
- {
- return $this->subject;
- }
-
- public function getArgument(string $key)
- {
- if ($this->hasArgument($key)) {
- return $this->arguments[$key];
- }
- throw new \InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
- }
-
- public function setArgument(string $key, $value)
- {
- $this->arguments[$key] = $value;
- return $this;
- }
-
- public function getArguments()
- {
- return $this->arguments;
- }
-
- public function setArguments(array $args = [])
- {
- $this->arguments = $args;
- return $this;
- }
-
- public function hasArgument(string $key)
- {
- return \array_key_exists($key, $this->arguments);
- }
-
-
- public function offsetGet($key)
- {
- return $this->getArgument($key);
- }
-
-
- public function offsetSet($key, $value)
- {
- $this->setArgument($key, $value);
- }
-
-
- public function offsetUnset($key)
- {
- if ($this->hasArgument($key)) {
- unset($this->arguments[$key]);
- }
- }
-
-
- public function offsetExists($key)
- {
- return $this->hasArgument($key);
- }
-
-
- public function getIterator()
- {
- return new \ArrayIterator($this->arguments);
- }
- }
|