SyncSystemAddressBook.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Thomas Müller <thomas.mueller@tmit.eu>
  6. *
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OCA\DAV\Command;
  23. use OCA\DAV\CardDAV\SyncService;
  24. use OCP\IUserManager;
  25. use Symfony\Component\Console\Command\Command;
  26. use Symfony\Component\Console\Helper\ProgressBar;
  27. use Symfony\Component\Console\Input\InputArgument;
  28. use Symfony\Component\Console\Input\InputInterface;
  29. use Symfony\Component\Console\Output\OutputInterface;
  30. class SyncSystemAddressBook extends Command {
  31. /** @var SyncService */
  32. private $syncService;
  33. /**
  34. * @param SyncService $syncService
  35. */
  36. function __construct(SyncService $syncService) {
  37. parent::__construct();
  38. $this->syncService = $syncService;
  39. }
  40. protected function configure() {
  41. $this
  42. ->setName('dav:sync-system-addressbook')
  43. ->setDescription('Synchronizes users to the system addressbook');
  44. }
  45. /**
  46. * @param InputInterface $input
  47. * @param OutputInterface $output
  48. */
  49. protected function execute(InputInterface $input, OutputInterface $output) {
  50. $output->writeln('Syncing users ...');
  51. $progress = new ProgressBar($output);
  52. $progress->start();
  53. $this->syncService->syncInstance(function() use ($progress) {
  54. $progress->advance();
  55. });
  56. $progress->finish();
  57. $output->writeln('');
  58. }
  59. }