SyncSystemAddressBook.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 Symfony\Component\Console\Command\Command;
  25. use Symfony\Component\Console\Helper\ProgressBar;
  26. use Symfony\Component\Console\Input\InputInterface;
  27. use Symfony\Component\Console\Output\OutputInterface;
  28. class SyncSystemAddressBook extends Command {
  29. /** @var SyncService */
  30. private $syncService;
  31. /**
  32. * @param SyncService $syncService
  33. */
  34. function __construct(SyncService $syncService) {
  35. parent::__construct();
  36. $this->syncService = $syncService;
  37. }
  38. protected function configure() {
  39. $this
  40. ->setName('dav:sync-system-addressbook')
  41. ->setDescription('Synchronizes users to the system addressbook');
  42. }
  43. /**
  44. * @param InputInterface $input
  45. * @param OutputInterface $output
  46. */
  47. protected function execute(InputInterface $input, OutputInterface $output) {
  48. $output->writeln('Syncing users ...');
  49. $progress = new ProgressBar($output);
  50. $progress->start();
  51. $this->syncService->syncInstance(function() use ($progress) {
  52. $progress->advance();
  53. });
  54. $progress->finish();
  55. $output->writeln('');
  56. }
  57. }