1
0

QueuedJob.php 963 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\BackgroundJob;
  8. use OCP\ILogger;
  9. /**
  10. * Simple base class for a one time background job
  11. *
  12. * @since 15.0.0
  13. */
  14. abstract class QueuedJob extends Job {
  15. /**
  16. * Run the job, then remove it from the joblist
  17. *
  18. * @param IJobList $jobList
  19. * @param ILogger|null $logger
  20. *
  21. * @since 15.0.0
  22. * @deprecated since 25.0.0 Use start() instead. This method will be removed
  23. * with the ILogger interface
  24. */
  25. final public function execute($jobList, ?ILogger $logger = null) {
  26. $this->start($jobList);
  27. }
  28. /**
  29. * Run the job, then remove it from the joblist
  30. *
  31. * @since 25.0.0
  32. */
  33. final public function start(IJobList $jobList): void {
  34. if ($this->id) {
  35. $jobList->removeById($this->id);
  36. } else {
  37. $jobList->remove($this, $this->argument);
  38. }
  39. parent::start($jobList);
  40. }
  41. }