1
0

RegenerateBirthdayCalendars.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\DAV\Migration;
  7. use OCA\DAV\BackgroundJob\RegisterRegenerateBirthdayCalendars;
  8. use OCP\BackgroundJob\IJobList;
  9. use OCP\IConfig;
  10. use OCP\Migration\IOutput;
  11. use OCP\Migration\IRepairStep;
  12. class RegenerateBirthdayCalendars implements IRepairStep {
  13. /** @var IJobList */
  14. private $jobList;
  15. /** @var IConfig */
  16. private $config;
  17. /**
  18. * @param IJobList $jobList
  19. * @param IConfig $config
  20. */
  21. public function __construct(IJobList $jobList,
  22. IConfig $config) {
  23. $this->jobList = $jobList;
  24. $this->config = $config;
  25. }
  26. /**
  27. * @return string
  28. */
  29. public function getName() {
  30. return 'Regenerating birthday calendars to use new icons and fix old birthday events without year';
  31. }
  32. /**
  33. * @param IOutput $output
  34. */
  35. public function run(IOutput $output) {
  36. // only run once
  37. if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') {
  38. $output->info('Repair step already executed');
  39. return;
  40. }
  41. $output->info('Adding background jobs to regenerate birthday calendar');
  42. $this->jobList->add(RegisterRegenerateBirthdayCalendars::class);
  43. // if all were done, no need to redo the repair during next upgrade
  44. $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes');
  45. }
  46. }