]> source.dussan.org Git - nextcloud-server.git/commitdiff
CardDavBackEnd requires principalBackend on ctor
authorThomas Müller <thomas.mueller@tmit.eu>
Wed, 25 Nov 2015 11:27:25 +0000 (12:27 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Wed, 25 Nov 2015 20:14:16 +0000 (21:14 +0100)
apps/dav/appinfo/register_command.php
apps/dav/command/createaddressbook.php

index 7d57b944fb2772441c2c6e6f4a2a0a92a1183cf6..1f0df054110cf5f7f1575dd8c0b050b5dba5c078 100644 (file)
@@ -5,6 +5,8 @@ use OCA\DAV\Command\CreateCalendar;
 
 $dbConnection = \OC::$server->getDatabaseConnection();
 $userManager = OC::$server->getUserManager();
+$config = \OC::$server->getConfig();
+
 /** @var Symfony\Component\Console\Application $application */
-$application->add(new CreateAddressBook($userManager, $dbConnection));
+$application->add(new CreateAddressBook($userManager, $dbConnection, $config));
 $application->add(new CreateCalendar($userManager, $dbConnection));
index 286871b39e2762d53abbacf6e89a8c59d9400531..371ea44121d02463f94d0dd0d5956c1ea96f8633 100644 (file)
@@ -3,6 +3,8 @@
 namespace OCA\DAV\Command;
 
 use OCA\DAV\CardDAV\CardDavBackend;
+use OCA\DAV\Connector\Sabre\Principal;
+use OCP\IConfig;
 use OCP\IDBConnection;
 use OCP\IUserManager;
 use Symfony\Component\Console\Command\Command;
@@ -18,26 +20,30 @@ class CreateAddressBook extends Command {
        /** @var \OCP\IDBConnection */
        protected $dbConnection;
 
+       /** @var IConfig */
+       private $config;
+
        /**
         * @param IUserManager $userManager
         * @param IDBConnection $dbConnection
         */
-       function __construct(IUserManager $userManager, IDBConnection $dbConnection) {
+       function __construct(IUserManager $userManager, IDBConnection $dbConnection, IConfig $config) {
                parent::__construct();
                $this->userManager = $userManager;
                $this->dbConnection = $dbConnection;
+               $this->config = $config;
        }
 
        protected function configure() {
                $this
-                       ->setName('dav:create-addressbook')
-                       ->setDescription('Create a dav addressbook')
-                       ->addArgument('user',
-                               InputArgument::REQUIRED,
-                               'User for whom the addressbook will be created')
-                       ->addArgument('name',
-                               InputArgument::REQUIRED,
-                               'Name of the addressbook');
+                               ->setName('dav:create-addressbook')
+                               ->setDescription('Create a dav addressbook')
+                               ->addArgument('user',
+                                               InputArgument::REQUIRED,
+                                               'User for whom the addressbook will be created')
+                               ->addArgument('name',
+                                               InputArgument::REQUIRED,
+                                               'Name of the addressbook');
        }
 
        protected function execute(InputInterface $input, OutputInterface $output) {
@@ -45,8 +51,13 @@ class CreateAddressBook extends Command {
                if (!$this->userManager->userExists($user)) {
                        throw new \InvalidArgumentException("User <$user> in unknown.");
                }
+               $principalBackend = new Principal(
+                               $this->config,
+                               $this->userManager
+               );
+
                $name = $input->getArgument('name');
-               $carddav = new CardDavBackend($this->dbConnection);
+               $carddav = new CardDavBackend($this->dbConnection, $principalBackend);
                $carddav->createAddressBook("principals/$user", $name, []);
        }
 }