1
0

RegenerateBirthdayCalendars.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. /**
  14. * @param IJobList $jobList
  15. * @param IConfig $config
  16. */
  17. public function __construct(
  18. private IJobList $jobList,
  19. private IConfig $config,
  20. ) {
  21. }
  22. /**
  23. * @return string
  24. */
  25. public function getName() {
  26. return 'Regenerating birthday calendars to use new icons and fix old birthday events without year';
  27. }
  28. /**
  29. * @param IOutput $output
  30. */
  31. public function run(IOutput $output) {
  32. // only run once
  33. if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') {
  34. $output->info('Repair step already executed');
  35. return;
  36. }
  37. $output->info('Adding background jobs to regenerate birthday calendar');
  38. $this->jobList->add(RegisterRegenerateBirthdayCalendars::class);
  39. // if all were done, no need to redo the repair during next upgrade
  40. $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes');
  41. }
  42. }