@@ -43,145 +43,145 @@ |
||
| 43 | 43 | * @deprecated 22.0.0 use \OCP\EventDispatcher\Event |
| 44 | 44 | */ |
| 45 | 45 | class GenericEvent extends Event implements ArrayAccess, IteratorAggregate { |
| 46 | - /** @deprecated 22.0.0 */ |
|
| 47 | - protected $subject; |
|
| 48 | - |
|
| 49 | - /** @deprecated 22.0.0 */ |
|
| 50 | - protected $arguments; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Encapsulate an event with $subject and $args. |
|
| 54 | - * |
|
| 55 | - * @since 18.0.0 |
|
| 56 | - * @deprecated 22.0.0 |
|
| 57 | - */ |
|
| 58 | - public function __construct($subject = null, array $arguments = []) { |
|
| 59 | - parent::__construct(); |
|
| 60 | - $this->subject = $subject; |
|
| 61 | - $this->arguments = $arguments; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Getter for subject property. |
|
| 66 | - * |
|
| 67 | - * @since 18.0.0 |
|
| 68 | - * @deprecated 22.0.0 |
|
| 69 | - */ |
|
| 70 | - public function getSubject() { |
|
| 71 | - return $this->subject; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Get argument by key. |
|
| 76 | - * |
|
| 77 | - * @throws InvalidArgumentException if key is not found |
|
| 78 | - * @since 18.0.0 |
|
| 79 | - * @deprecated 22.0.0 |
|
| 80 | - */ |
|
| 81 | - public function getArgument(string $key) { |
|
| 82 | - if ($this->hasArgument($key)) { |
|
| 83 | - return $this->arguments[$key]; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - throw new InvalidArgumentException(sprintf('Argument "%s" not found.', $key)); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Add argument to event. |
|
| 91 | - * |
|
| 92 | - * @since 18.0.0 |
|
| 93 | - * @deprecated 22.0.0 |
|
| 94 | - */ |
|
| 95 | - public function setArgument($key, $value): GenericEvent { |
|
| 96 | - $this->arguments[$key] = $value; |
|
| 97 | - return $this; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Getter for all arguments. |
|
| 102 | - * |
|
| 103 | - * @since 18.0.0 |
|
| 104 | - * @deprecated 22.0.0 |
|
| 105 | - */ |
|
| 106 | - public function getArguments(): array { |
|
| 107 | - return $this->arguments; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Set args property. |
|
| 112 | - * |
|
| 113 | - * @since 18.0.0 |
|
| 114 | - * @deprecated 22.0.0 |
|
| 115 | - */ |
|
| 116 | - public function setArguments(array $args = []): GenericEvent { |
|
| 117 | - $this->arguments = $args; |
|
| 118 | - return $this; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Has argument. |
|
| 123 | - * |
|
| 124 | - * @since 18.0.0 |
|
| 125 | - * @deprecated 22.0.0 |
|
| 126 | - */ |
|
| 127 | - public function hasArgument($key): bool { |
|
| 128 | - return array_key_exists($key, $this->arguments); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Retrieve an external iterator |
|
| 133 | - * |
|
| 134 | - * @link https://php.net/manual/en/iteratoraggregate.getiterator.php |
|
| 135 | - * @since 18.0.0 |
|
| 136 | - * @deprecated 22.0.0 |
|
| 137 | - */ |
|
| 138 | - public function getIterator(): Traversable { |
|
| 139 | - return new ArrayIterator($this->arguments); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Whether a offset exists |
|
| 144 | - * |
|
| 145 | - * @link https://php.net/manual/en/arrayaccess.offsetexists.php |
|
| 146 | - * @since 18.0.0 |
|
| 147 | - * @deprecated 22.0.0 |
|
| 148 | - */ |
|
| 149 | - public function offsetExists($offset): bool { |
|
| 150 | - return $this->hasArgument($offset); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Offset to retrieve |
|
| 155 | - * |
|
| 156 | - * @link https://php.net/manual/en/arrayaccess.offsetget.php |
|
| 157 | - * @since 18.0.0 |
|
| 158 | - * @deprecated 22.0.0 |
|
| 159 | - */ |
|
| 160 | - public function offsetGet($offset) { |
|
| 161 | - return $this->arguments[$offset]; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Offset to set |
|
| 166 | - * |
|
| 167 | - * @link https://php.net/manual/en/arrayaccess.offsetset.php |
|
| 168 | - * @since 18.0.0 |
|
| 169 | - * @deprecated 22.0.0 |
|
| 170 | - */ |
|
| 171 | - public function offsetSet($offset, $value): void { |
|
| 172 | - $this->setArgument($offset, $value); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Offset to unset |
|
| 177 | - * |
|
| 178 | - * @link https://php.net/manual/en/arrayaccess.offsetunset.php |
|
| 179 | - * @since 18.0.0 |
|
| 180 | - * @deprecated 22.0.0 |
|
| 181 | - */ |
|
| 182 | - public function offsetUnset($offset): void { |
|
| 183 | - if ($this->hasArgument($offset)) { |
|
| 184 | - unset($this->arguments[$offset]); |
|
| 185 | - } |
|
| 186 | - } |
|
| 46 | + /** @deprecated 22.0.0 */ |
|
| 47 | + protected $subject; |
|
| 48 | + |
|
| 49 | + /** @deprecated 22.0.0 */ |
|
| 50 | + protected $arguments; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Encapsulate an event with $subject and $args. |
|
| 54 | + * |
|
| 55 | + * @since 18.0.0 |
|
| 56 | + * @deprecated 22.0.0 |
|
| 57 | + */ |
|
| 58 | + public function __construct($subject = null, array $arguments = []) { |
|
| 59 | + parent::__construct(); |
|
| 60 | + $this->subject = $subject; |
|
| 61 | + $this->arguments = $arguments; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Getter for subject property. |
|
| 66 | + * |
|
| 67 | + * @since 18.0.0 |
|
| 68 | + * @deprecated 22.0.0 |
|
| 69 | + */ |
|
| 70 | + public function getSubject() { |
|
| 71 | + return $this->subject; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Get argument by key. |
|
| 76 | + * |
|
| 77 | + * @throws InvalidArgumentException if key is not found |
|
| 78 | + * @since 18.0.0 |
|
| 79 | + * @deprecated 22.0.0 |
|
| 80 | + */ |
|
| 81 | + public function getArgument(string $key) { |
|
| 82 | + if ($this->hasArgument($key)) { |
|
| 83 | + return $this->arguments[$key]; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + throw new InvalidArgumentException(sprintf('Argument "%s" not found.', $key)); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Add argument to event. |
|
| 91 | + * |
|
| 92 | + * @since 18.0.0 |
|
| 93 | + * @deprecated 22.0.0 |
|
| 94 | + */ |
|
| 95 | + public function setArgument($key, $value): GenericEvent { |
|
| 96 | + $this->arguments[$key] = $value; |
|
| 97 | + return $this; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Getter for all arguments. |
|
| 102 | + * |
|
| 103 | + * @since 18.0.0 |
|
| 104 | + * @deprecated 22.0.0 |
|
| 105 | + */ |
|
| 106 | + public function getArguments(): array { |
|
| 107 | + return $this->arguments; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Set args property. |
|
| 112 | + * |
|
| 113 | + * @since 18.0.0 |
|
| 114 | + * @deprecated 22.0.0 |
|
| 115 | + */ |
|
| 116 | + public function setArguments(array $args = []): GenericEvent { |
|
| 117 | + $this->arguments = $args; |
|
| 118 | + return $this; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Has argument. |
|
| 123 | + * |
|
| 124 | + * @since 18.0.0 |
|
| 125 | + * @deprecated 22.0.0 |
|
| 126 | + */ |
|
| 127 | + public function hasArgument($key): bool { |
|
| 128 | + return array_key_exists($key, $this->arguments); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Retrieve an external iterator |
|
| 133 | + * |
|
| 134 | + * @link https://php.net/manual/en/iteratoraggregate.getiterator.php |
|
| 135 | + * @since 18.0.0 |
|
| 136 | + * @deprecated 22.0.0 |
|
| 137 | + */ |
|
| 138 | + public function getIterator(): Traversable { |
|
| 139 | + return new ArrayIterator($this->arguments); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Whether a offset exists |
|
| 144 | + * |
|
| 145 | + * @link https://php.net/manual/en/arrayaccess.offsetexists.php |
|
| 146 | + * @since 18.0.0 |
|
| 147 | + * @deprecated 22.0.0 |
|
| 148 | + */ |
|
| 149 | + public function offsetExists($offset): bool { |
|
| 150 | + return $this->hasArgument($offset); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Offset to retrieve |
|
| 155 | + * |
|
| 156 | + * @link https://php.net/manual/en/arrayaccess.offsetget.php |
|
| 157 | + * @since 18.0.0 |
|
| 158 | + * @deprecated 22.0.0 |
|
| 159 | + */ |
|
| 160 | + public function offsetGet($offset) { |
|
| 161 | + return $this->arguments[$offset]; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Offset to set |
|
| 166 | + * |
|
| 167 | + * @link https://php.net/manual/en/arrayaccess.offsetset.php |
|
| 168 | + * @since 18.0.0 |
|
| 169 | + * @deprecated 22.0.0 |
|
| 170 | + */ |
|
| 171 | + public function offsetSet($offset, $value): void { |
|
| 172 | + $this->setArgument($offset, $value); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Offset to unset |
|
| 177 | + * |
|
| 178 | + * @link https://php.net/manual/en/arrayaccess.offsetunset.php |
|
| 179 | + * @since 18.0.0 |
|
| 180 | + * @deprecated 22.0.0 |
|
| 181 | + */ |
|
| 182 | + public function offsetUnset($offset): void { |
|
| 183 | + if ($this->hasArgument($offset)) { |
|
| 184 | + unset($this->arguments[$offset]); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | 187 | } |