1
0

TimedJob.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <robin@icewind.nl>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\BackgroundJob;
  27. use OCP\BackgroundJob\IJobList;
  28. use OCP\ILogger;
  29. /**
  30. * Class QueuedJob
  31. *
  32. * create a background job that is to be executed at an interval
  33. *
  34. * @package OC\BackgroundJob
  35. *
  36. * @deprecated internal class, use \OCP\BackgroundJob\TimedJob
  37. */
  38. abstract class TimedJob extends Job {
  39. protected $interval = 0;
  40. /**
  41. * set the interval for the job
  42. *
  43. * @param int $interval
  44. */
  45. public function setInterval($interval) {
  46. $this->interval = $interval;
  47. }
  48. /**
  49. * run the job if
  50. *
  51. * @param IJobList $jobList
  52. * @param ILogger|null $logger
  53. */
  54. public function execute($jobList, ILogger $logger = null) {
  55. if ((time() - $this->lastRun) > $this->interval) {
  56. parent::execute($jobList, $logger);
  57. }
  58. }
  59. }