From b02dea29e6b60f174d22be3899370c2f41a3bae3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20M=C3=BCller?= Date: Wed, 25 Nov 2015 12:27:25 +0100 Subject: [PATCH] CardDavBackEnd requires principalBackend on ctor --- apps/dav/appinfo/register_command.php | 4 +++- apps/dav/command/createaddressbook.php | 31 +++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/apps/dav/appinfo/register_command.php b/apps/dav/appinfo/register_command.php index 7d57b944fb2..1f0df054110 100644 --- a/apps/dav/appinfo/register_command.php +++ b/apps/dav/appinfo/register_command.php @@ -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)); diff --git a/apps/dav/command/createaddressbook.php b/apps/dav/command/createaddressbook.php index 286871b39e2..371ea44121d 100644 --- a/apps/dav/command/createaddressbook.php +++ b/apps/dav/command/createaddressbook.php @@ -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, []); } } -- 2.39.5