]> source.dussan.org Git - nextcloud-server.git/commitdiff
Inject DbHandler ....
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 17 Dec 2015 16:01:24 +0000 (17:01 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 12 Jan 2016 13:24:47 +0000 (14:24 +0100)
apps/federation/appinfo/register_command.php
apps/federation/command/syncfederationaddressbooks.php

index 28829ccfca15953d519688c59a47c62b1d74be22..541b01706d034b8d19efd89105d0933da85c576d 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 
 $dbConnection = \OC::$server->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));
index d152f1b19db8b02aab0e9a31499915d162272f72..d7761d14814b1d6bdae1ff343323ea23d36b4446 100644 (file)
@@ -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();