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->setUserId($userId);
|
||||
$subscription->setCollectionName($collectionName);
|
||||
$subscription->setTransport($transport);
|
||||
$subscription->setCreationTimestamp($creationTimestamp ?? time());
|
||||
$subscription->setExpirationTimestamp($expirationTimestamp);
|
||||
$subscription->setData(json_encode($data));
|
||||
$subscription = $this->mapper->insert($subscription);
|
||||
|
||||
return $subscription;
|
||||
|
|
|
@ -27,18 +27,21 @@ declare(strict_types=1);
|
|||
namespace OCA\DavPush\Transport;
|
||||
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Server;
|
||||
|
||||
use OCA\DavPush\Events\RegisterTransportsEvent;
|
||||
use OCA\DavPush\PushTransports\WebPushTransport;
|
||||
use OCA\DavPush\PushTransports\WebhookTransport;
|
||||
//use OCA\DavPush\PushTransports\WebhookTransport;
|
||||
|
||||
class TransportManager {
|
||||
private array $transports = [];
|
||||
|
||||
public function __construct(IEventDispatcher $dispatcher) {
|
||||
public function __construct(
|
||||
IEventDispatcher $dispatcher,
|
||||
) {
|
||||
// register integrated transports
|
||||
$this->registerTransport(new WebPushTransport());
|
||||
$this->registerTransport(new WebhookTransport());
|
||||
$this->registerTransport(Server::get(WebPushTransport::class));
|
||||
//$this->registerTransport(ContainerInterface::get(WebhookTransport::class));
|
||||
|
||||
// register transports provided by other apps
|
||||
$event = new RegisterTransportsEvent($this);
|
||||
|
|
Loading…
Reference in a new issue