job.php 871 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace OC\BackgroundJob;
  9. abstract class Job {
  10. protected $id;
  11. protected $lastRun;
  12. protected $argument;
  13. /**
  14. * @param JobList $jobList
  15. */
  16. public function execute($jobList) {
  17. $jobList->setLastRun($this);
  18. $this->run($this->argument);
  19. }
  20. abstract protected function run($argument);
  21. public function setId($id) {
  22. $this->id = $id;
  23. }
  24. public function setLastRun($lastRun) {
  25. $this->lastRun = $lastRun;
  26. }
  27. public function setArgument($argument) {
  28. $this->argument = $argument;
  29. }
  30. public function getId() {
  31. return $this->id;
  32. }
  33. public function getLastRun() {
  34. return $this->lastRun;
  35. }
  36. public function getArgument() {
  37. return $this->argument;
  38. }
  39. }