use container to allow dependency injection in transport classes
This commit is contained in:
parent
f994a182d3
commit
ec6e69e240
2 changed files with 8 additions and 6 deletions
|
@ -43,14 +43,13 @@ class SubscriptionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(string $userId, string $collectionName, string $transport, int $expirationTimestamp, $data, ?int $creationTimestamp = null) {
|
public function create(string $userId, string $collectionName, string $transport, int $expirationTimestamp, ?int $creationTimestamp = null) {
|
||||||
$subscription = new Subscription();
|
$subscription = new Subscription();
|
||||||
$subscription->setUserId($userId);
|
$subscription->setUserId($userId);
|
||||||
$subscription->setCollectionName($collectionName);
|
$subscription->setCollectionName($collectionName);
|
||||||
$subscription->setTransport($transport);
|
$subscription->setTransport($transport);
|
||||||
$subscription->setCreationTimestamp($creationTimestamp ?? time());
|
$subscription->setCreationTimestamp($creationTimestamp ?? time());
|
||||||
$subscription->setExpirationTimestamp($expirationTimestamp);
|
$subscription->setExpirationTimestamp($expirationTimestamp);
|
||||||
$subscription->setData(json_encode($data));
|
|
||||||
$subscription = $this->mapper->insert($subscription);
|
$subscription = $this->mapper->insert($subscription);
|
||||||
|
|
||||||
return $subscription;
|
return $subscription;
|
||||||
|
|
|
@ -27,18 +27,21 @@ declare(strict_types=1);
|
||||||
namespace OCA\DavPush\Transport;
|
namespace OCA\DavPush\Transport;
|
||||||
|
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
|
use OCP\Server;
|
||||||
|
|
||||||
use OCA\DavPush\Events\RegisterTransportsEvent;
|
use OCA\DavPush\Events\RegisterTransportsEvent;
|
||||||
use OCA\DavPush\PushTransports\WebPushTransport;
|
use OCA\DavPush\PushTransports\WebPushTransport;
|
||||||
use OCA\DavPush\PushTransports\WebhookTransport;
|
//use OCA\DavPush\PushTransports\WebhookTransport;
|
||||||
|
|
||||||
class TransportManager {
|
class TransportManager {
|
||||||
private array $transports = [];
|
private array $transports = [];
|
||||||
|
|
||||||
public function __construct(IEventDispatcher $dispatcher) {
|
public function __construct(
|
||||||
|
IEventDispatcher $dispatcher,
|
||||||
|
) {
|
||||||
// register integrated transports
|
// register integrated transports
|
||||||
$this->registerTransport(new WebPushTransport());
|
$this->registerTransport(Server::get(WebPushTransport::class));
|
||||||
$this->registerTransport(new WebhookTransport());
|
//$this->registerTransport(ContainerInterface::get(WebhookTransport::class));
|
||||||
|
|
||||||
// register transports provided by other apps
|
// register transports provided by other apps
|
||||||
$event = new RegisterTransportsEvent($this);
|
$event = new RegisterTransportsEvent($this);
|
||||||
|
|
Loading…
Reference in a new issue