From 9f15e091e16c253637d5fb2a1a9f2a110bd7b147 Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Wed, 12 Jun 2024 01:51:00 +0200 Subject: [PATCH] change transports registration to save as dict items by id instead of array --- lib/Transport/TransportManager.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Transport/TransportManager.php b/lib/Transport/TransportManager.php index 27a6cc2..95283d7 100644 --- a/lib/Transport/TransportManager.php +++ b/lib/Transport/TransportManager.php @@ -32,9 +32,6 @@ use OCA\DavPush\Events\RegisterTransportsEvent; use OCA\DavPush\PushTransports\WebPushTransport; class TransportManager { - /** - * @var Transport[] - */ private array $transports = []; public function __construct(IEventDispatcher $dispatcher) { @@ -53,8 +50,15 @@ class TransportManager { return $this->transports; } + /** + * @return Transport + */ + public function getTransport($id): ?Transport { + return $this->transports[$id]; + } + public function registerTransport(Transport $transport): self { - $this->transports[] = $transport; + $this->transports[$transport->getId()] = $transport; return $this; } } \ No newline at end of file