Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Log deprecation notice of GenericEventWrapper just once
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Feb 5, 2021
commit 91e1707498a6ceb3f85490acb4d85b371444bfbd
8 changes: 8 additions & 0 deletions lib/private/EventDispatcher/GenericEventWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class GenericEventWrapper extends GenericEvent {
/** @var string */
private $eventName;

/** @var bool */
private $deprecationNoticeLogged = false;

public function __construct(ILogger $logger, string $eventName, ?GenericEvent $event) {
parent::__construct($eventName);
$this->logger = $logger;
Expand All @@ -49,11 +52,16 @@ public function __construct(ILogger $logger, string $eventName, ?GenericEvent $e
}

private function log() {
if ($this->deprecationNoticeLogged) {
return;
}

$class = ($this->event !== null && is_object($this->event)) ? get_class($this->event) : 'null';
$this->logger->info(
'Deprecated event type for {name}: {class} is used',
[ 'name' => $this->eventName, 'class' => $class]
);
$this->deprecationNoticeLogged = true;
}

public function isPropagationStopped(): bool {
Expand Down