From 693617d8a5b566454a2d18ff4cb9bcfd8559f3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 17 Dec 2015 17:01:24 +0100 Subject: [PATCH] Inject DbHandler .... --- apps/federation/appinfo/register_command.php | 4 +++- .../command/syncfederationaddressbooks.php | 15 +++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/federation/appinfo/register_command.php b/apps/federation/appinfo/register_command.php index 28829ccfca1..541b01706d0 100644 --- a/apps/federation/appinfo/register_command.php +++ b/apps/federation/appinfo/register_command.php @@ -1,6 +1,8 @@ getDatabaseConnection(); +$l10n = \OC::$server->getL10N('federation'); +$dbHandler = new \OCA\Federation\DbHandler($dbConnection, $l10n); /** @var Symfony\Component\Console\Application $application */ -$application->add(new \OCA\Federation\Command\SyncFederationAddressBooks($dbConnection)); +$application->add(new \OCA\Federation\Command\SyncFederationAddressBooks($dbHandler)); diff --git a/apps/federation/command/syncfederationaddressbooks.php b/apps/federation/command/syncfederationaddressbooks.php index d152f1b19db..d7761d14814 100644 --- a/apps/federation/command/syncfederationaddressbooks.php +++ b/apps/federation/command/syncfederationaddressbooks.php @@ -16,22 +16,22 @@ use Symfony\Component\Console\Output\OutputInterface; class SyncFederationAddressBooks extends Command { - /** @var \OCP\IDBConnection */ - protected $dbConnection; + /** @var DbHandler */ + protected $dbHandler; /** @var SyncService */ private $syncService; /** * @param IUserManager $userManager - * @param IDBConnection $dbConnection + * @param IDBConnection $dbHandler * @param IConfig $config */ - function __construct(IDBConnection $dbConnection) { + function __construct(DbHandler $dbHandler) { parent::__construct(); $this->syncService = \OC::$server->query('CardDAVSyncService'); - $this->dbConnection = $dbConnection; + $this->dbHandler = $dbHandler; } protected function configure() { @@ -48,8 +48,7 @@ class SyncFederationAddressBooks extends Command { $progress = new ProgressBar($output); $progress->start(); - $db = new DbHandler($this->dbConnection, null); - $trustedServers = $db->getAllServer(); + $trustedServers = $this->dbHandler->getAllServer(); foreach ($trustedServers as $trustedServer) { $progress->advance(); $url = $trustedServer['url']; @@ -66,7 +65,7 @@ class SyncFederationAddressBooks extends Command { ]; $newToken = $this->syncService->syncRemoteAddressBook($url, 'system', $sharedSecret, $syncToken, $targetPrincipal, $targetBookId, $targetBookProperties); if ($newToken !== $syncToken) { - $db->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); + $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); } } $progress->finish();