2020-05-11 10:27:17 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OC\EventDispatcher;
|
|
|
|
|
|
|
|
use OCP\ILogger;
|
|
|
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
|
|
|
|
|
|
|
class GenericEventWrapper extends GenericEvent {
|
|
|
|
|
|
|
|
/** @var ILogger */
|
|
|
|
private $logger;
|
|
|
|
|
|
|
|
/** @var GenericEvent */
|
|
|
|
private $event;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
private $eventName;
|
|
|
|
|
|
|
|
public function __construct(ILogger $logger, string $eventName, ?GenericEvent $event) {
|
2020-06-08 10:42:45 +03:00
|
|
|
parent::__construct($eventName);
|
2020-05-11 10:27:17 +03:00
|
|
|
$this->logger = $logger;
|
|
|
|
$this->event = $event;
|
|
|
|
$this->eventName = $eventName;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function log() {
|
2020-06-08 10:42:45 +03:00
|
|
|
$class = ($this->event !== null && is_object($this->event)) ? get_class($this->event) : 'null';
|
2020-05-11 10:27:17 +03:00
|
|
|
$this->logger->info(
|
|
|
|
'Deprecated event type for {name}: {class} is used',
|
2020-06-08 10:42:45 +03:00
|
|
|
[ 'name' => $this->eventName, 'class' => $class]
|
2020-05-11 10:27:17 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-08 10:42:45 +03:00
|
|
|
public function isPropagationStopped(): bool {
|
2020-05-11 10:27:17 +03:00
|
|
|
$this->log();
|
|
|
|
return $this->event->isPropagationStopped();
|
|
|
|
}
|
|
|
|
|
2020-06-08 10:42:45 +03:00
|
|
|
public function stopPropagation(): void {
|
2020-05-11 10:27:17 +03:00
|
|
|
$this->log();
|
|
|
|
$this->event->stopPropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSubject() {
|
|
|
|
$this->log();
|
|
|
|
return $this->event->getSubject();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArgument($key) {
|
|
|
|
$this->log();
|
|
|
|
return $this->event->getArgument($key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setArgument($key, $value) {
|
|
|
|
$this->log();
|
|
|
|
return $this->event->setArgument($key, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArguments() {
|
|
|
|
return $this->event->getArguments();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setArguments(array $args = []) {
|
|
|
|
return $this->event->setArguments($args);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasArgument($key) {
|
|
|
|
return $this->event->hasArgument($key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function offsetGet($key) {
|
|
|
|
return $this->event->offsetGet($key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function offsetSet($key, $value) {
|
|
|
|
return $this->event->offsetSet($key, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function offsetUnset($key) {
|
|
|
|
return $this->event->offsetUnset($key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function offsetExists($key) {
|
|
|
|
return $this->event->offsetExists($key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIterator() {
|
|
|
|
return$this->event->getIterator();
|
|
|
|
}
|
|
|
|
}
|