aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/BackgroundJob/QueuedJob.php
blob: 75e27d1d60fb962b97277f0d521949447130ef60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCP\BackgroundJob;

use OCP\ILogger;

/**
 * Simple base class for a one time background job
 *
 * @since 15.0.0
 */
abstract class QueuedJob extends Job {
	/**
	 * Run the job, then remove it from the joblist
	 *
	 * @param IJobList $jobList
	 * @param ILogger|null $logger
	 *
	 * @since 15.0.0
	 * @deprecated 25.0.0 Use start() instead. This method will be removed
	 * with the ILogger interface
	 */
	final public function execute($jobList, ?ILogger $logger = null) {
		$this->start($jobList);
	}

	/**
	 * Run the job, then remove it from the joblist
	 *
	 * @since 25.0.0
	 */
	final public function start(IJobList $jobList): void {
		if ($this->id) {
			$jobList->removeById($this->id);
		} else {
			$jobList->remove($this, $this->argument);
		}
		parent::start($jobList);
	}
}