Reuse backend as provided by the app container

This commit is contained in:
Thomas Müller 2016-01-12 14:27:50 +01:00
parent 23a8c93fd2
commit bf1a2f28c2

View file

@ -21,18 +21,12 @@
use OCA\DAV\CardDAV\CardDavBackend; use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\CardDAV\SyncService; use OCA\DAV\CardDAV\SyncService;
use OCA\DAV\Connector\Sabre\Principal;
\OC::$server->registerService('CardDAVSyncService', function() { \OC::$server->registerService('CardDAVSyncService', function() {
$userManager = \OC::$server->getUserManager(); $app = new \OCA\Dav\AppInfo\Application();
$dbConnection = \OC::$server->getDatabaseConnection(); /** @var CardDavBackend */
$backend = $app->getContainer()->query('CardDavBackend');
$principalBackend = new Principal(
$userManager
);
$backend = new CardDavBackend($dbConnection, $principalBackend);
return new SyncService($backend); return new SyncService($backend);
}); });