aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/EventDispatcher
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-10-16 12:36:03 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2019-10-17 13:31:48 +0200
commite8095cf7372a8e95ca0f57ada1ddb8712aebce9a (patch)
tree4646cb85b358b7dcb9db9d163bc648d19f294ca3 /lib/private/EventDispatcher
parent9f2d15ad5ce0e011de2594c7993714c3001c8c47 (diff)
downloadnextcloud-server-e8095cf7372a8e95ca0f57ada1ddb8712aebce9a.tar.gz
nextcloud-server-e8095cf7372a8e95ca0f57ada1ddb8712aebce9a.zip
use OCP\EventDispatcher\Event over Symfony's deprecated Event
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/EventDispatcher')
-rw-r--r--lib/private/EventDispatcher/SymfonyAdapter.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/private/EventDispatcher/SymfonyAdapter.php b/lib/private/EventDispatcher/SymfonyAdapter.php
index f2f2fbf59fd..f8f80b6c5f8 100644
--- a/lib/private/EventDispatcher/SymfonyAdapter.php
+++ b/lib/private/EventDispatcher/SymfonyAdapter.php
@@ -25,9 +25,9 @@ declare(strict_types=1);
namespace OC\EventDispatcher;
+use OCP\ILogger;
use function is_callable;
use OCP\EventDispatcher\Event;
-use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -35,9 +35,12 @@ class SymfonyAdapter implements EventDispatcherInterface {
/** @var EventDispatcher */
private $eventDispatcher;
+ /** @var ILogger */
+ private $logger;
- public function __construct(EventDispatcher $eventDispatcher) {
+ public function __construct(EventDispatcher $eventDispatcher, ILogger $logger) {
$this->eventDispatcher = $eventDispatcher;
+ $this->logger = $logger;
}
/**
@@ -46,16 +49,21 @@ class SymfonyAdapter implements EventDispatcherInterface {
* @param string $eventName The name of the event to dispatch. The name of
* the event is the name of the method that is
* invoked on listeners.
- * @param SymfonyEvent|null $event The event to pass to the event handlers/listeners
+ * @param Event|null $event The event to pass to the event handlers/listeners
* If not supplied, an empty Event instance is created
*
- * @return SymfonyEvent
+ * @return void
*/
- public function dispatch($eventName, SymfonyEvent $event = null) {
+ public function dispatch($eventName, $event = null) {
+ // type hinting is not possible, due to usage of GenericEvent
if ($event instanceof Event) {
$this->eventDispatcher->dispatch($eventName, $event);
} else {
// Legacy event
+ $this->logger->info(
+ 'Deprecated event type for {name}: {class}',
+ [ 'name' => $eventName, 'class' => is_object($event) ? get_class($event) : 'null' ]
+ );
$this->eventDispatcher->getSymfonyDispatcher()->dispatch($eventName, $event);
}
}