1
0
Fork 0
nc_ext_dav_push/lib/Transport/TransportManager.php

38 lines
876 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace OCA\DavPush\Transport;
use OCP\EventDispatcher\IEventDispatcher;
use OCA\DavPush\Event\RegisterTransportsEvent;
use OCA\DavPush\PushTransports\WebPushTransport;
class TransportManager {
/**
* @var Transport[]
*/
private array $transports = [];
public function __construct(IEventDispatcher $dispatcher) {
// register integrated transports
$this->registerTransport(new WebPushTransport());
// register transports provided by other apps
$event = new RegisterTransportsEvent($this);
$dispatcher->dispatchTyped($event);
}
/**
* @return Transport[]
*/
public function getTransports(): array {
return $this->transports;
}
public function registerTransport(Transport $transport): self {
$this->transports[] = $transport;
return $this;
}
}