diff options
Diffstat (limited to 'lib/private/EventDispatcher')
-rw-r--r-- | lib/private/EventDispatcher/EventDispatcher.php | 4 | ||||
-rw-r--r-- | lib/private/EventDispatcher/ServiceEventListener.php | 27 |
2 files changed, 10 insertions, 21 deletions
diff --git a/lib/private/EventDispatcher/EventDispatcher.php b/lib/private/EventDispatcher/EventDispatcher.php index b7554c439ea..474c902013b 100644 --- a/lib/private/EventDispatcher/EventDispatcher.php +++ b/lib/private/EventDispatcher/EventDispatcher.php @@ -14,7 +14,7 @@ use OCP\Broadcast\Events\IBroadcastEvent; use OCP\EventDispatcher\ABroadcastedEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; -use OCP\IServerContainer; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyDispatcher; use function get_class; @@ -22,7 +22,7 @@ use function get_class; class EventDispatcher implements IEventDispatcher { public function __construct( private SymfonyDispatcher $dispatcher, - private IServerContainer $container, + private ContainerInterface $container, private LoggerInterface $logger, ) { // inject the event dispatcher into the logger diff --git a/lib/private/EventDispatcher/ServiceEventListener.php b/lib/private/EventDispatcher/ServiceEventListener.php index 03a986ec78c..f9cc85b4126 100644 --- a/lib/private/EventDispatcher/ServiceEventListener.php +++ b/lib/private/EventDispatcher/ServiceEventListener.php @@ -12,7 +12,7 @@ namespace OC\EventDispatcher; use OCP\AppFramework\QueryException; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\IServerContainer; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; use function sprintf; @@ -23,24 +23,13 @@ use function sprintf; * created by the service container */ final class ServiceEventListener { - /** @var IServerContainer */ - private $container; + private ?IEventListener $service = null; - /** @var string */ - private $class; - - /** @var LoggerInterface */ - private $logger; - - /** @var null|IEventListener */ - private $service; - - public function __construct(IServerContainer $container, - string $class, - LoggerInterface $logger) { - $this->container = $container; - $this->class = $class; - $this->logger = $logger; + public function __construct( + private ContainerInterface $container, + private string $class, + private LoggerInterface $logger, + ) { } public function __invoke(Event $event) { @@ -49,7 +38,7 @@ final class ServiceEventListener { // TODO: fetch from the app containers, otherwise any custom services, // parameters and aliases won't be resolved. // See https://github.com/nextcloud/server/issues/27793 for details. - $this->service = $this->container->query($this->class); + $this->service = $this->container->get($this->class); } catch (QueryException $e) { $this->logger->error( sprintf( |