1
0
Fork 0

change transports registration to save as dict items by id instead of array

This commit is contained in:
Jonathan Treffler 2024-06-12 01:51:00 +02:00
parent 05bbfe100d
commit 9f15e091e1

View file

@ -32,9 +32,6 @@ use OCA\DavPush\Events\RegisterTransportsEvent;
use OCA\DavPush\PushTransports\WebPushTransport; use OCA\DavPush\PushTransports\WebPushTransport;
class TransportManager { class TransportManager {
/**
* @var Transport[]
*/
private array $transports = []; private array $transports = [];
public function __construct(IEventDispatcher $dispatcher) { public function __construct(IEventDispatcher $dispatcher) {
@ -53,8 +50,15 @@ class TransportManager {
return $this->transports; return $this->transports;
} }
/**
* @return Transport
*/
public function getTransport($id): ?Transport {
return $this->transports[$id];
}
public function registerTransport(Transport $transport): self { public function registerTransport(Transport $transport): self {
$this->transports[] = $transport; $this->transports[$transport->getId()] = $transport;
return $this; return $this;
} }
} }