Merge pull request #21299 from nextcloud/fix/generic-event-wrapper-constructor-get-class

Fix missing parent constructor call and get_class usage in GenericEventWrapper
This commit is contained in:
Roeland Jago Douma 2020-06-08 11:26:23 +02:00 committed by GitHub
commit fd62a5b59a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -40,24 +40,26 @@ class GenericEventWrapper extends GenericEvent {
private $eventName; private $eventName;
public function __construct(ILogger $logger, string $eventName, ?GenericEvent $event) { public function __construct(ILogger $logger, string $eventName, ?GenericEvent $event) {
parent::__construct($eventName);
$this->logger = $logger; $this->logger = $logger;
$this->event = $event; $this->event = $event;
$this->eventName = $eventName; $this->eventName = $eventName;
} }
private function log() { private function log() {
$class = ($this->event !== null && is_object($this->event)) ? get_class($this->event) : 'null';
$this->logger->info( $this->logger->info(
'Deprecated event type for {name}: {class} is used', 'Deprecated event type for {name}: {class} is used',
[ 'name' => $this->eventName, 'class' => is_object($this->event) ? get_class($this->event) : 'null' ] [ 'name' => $this->eventName, 'class' => $class]
); );
} }
public function isPropagationStopped() { public function isPropagationStopped(): bool {
$this->log(); $this->log();
return $this->event->isPropagationStopped(); return $this->event->isPropagationStopped();
} }
public function stopPropagation() { public function stopPropagation(): void {
$this->log(); $this->log();
$this->event->stopPropagation(); $this->event->stopPropagation();
} }