|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Symbiote\QueuedJobs\Jobs; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Control\HTTPRequest; |
|
6
|
|
|
use SilverStripe\Core\Injector\Injector; |
|
7
|
|
|
use SilverStripe\Dev\BuildTask; |
|
8
|
|
|
use SilverStripe\ORM\DataObject; |
|
9
|
|
|
use Symbiote\QueuedJobs\Services\AbstractQueuedJob; |
|
10
|
|
|
use Symbiote\QueuedJobs\Services\QueuedJob; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* A job used to delete a data object. Typically used for deletes that need to happen on |
|
14
|
|
|
* a schedule, or where the delete may have some onflow affect that takes a while to |
|
15
|
|
|
* finish the deletion. |
|
16
|
|
|
* |
|
17
|
|
|
* @author [email protected] |
|
18
|
|
|
* @license BSD License http://silverstripe.org/bsd-license/ |
|
19
|
|
|
*/ |
|
20
|
|
|
class RunBuildTaskJob extends AbstractQueuedJob |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @param DataObject $node |
|
|
|
|
|
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct($taskClass = null, $queryString = null) |
|
26
|
|
|
{ |
|
27
|
|
|
if ($taskClass) { |
|
28
|
|
|
$this->TaskClass = $taskClass; |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
if ($queryString) { |
|
32
|
|
|
$this->QueryString = $queryString; |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
$this->currentStep = 0; |
|
36
|
|
|
$this->totalSteps = 1; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param string (default: Object) |
|
41
|
|
|
* |
|
42
|
|
|
* @return DataObject |
|
43
|
|
|
*/ |
|
44
|
|
|
protected function getObject($name = 'SilverStripe\\Core\\Object') |
|
45
|
|
|
{ |
|
46
|
|
|
return DataObject::get_by_id($this->TargetClass, $this->TargetID); |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getJobType() |
|
53
|
|
|
{ |
|
54
|
|
|
return QueuedJob::QUEUED; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getTitle() |
|
61
|
|
|
{ |
|
62
|
|
|
$taskName = $this->QueryString ? ($this->TaskClass . '?' . $this->QueryString) : $this->TaskClass; |
|
|
|
|
|
|
63
|
|
|
return _t('RunBuildTaskJob.JOB_TITLE', 'Run BuildTask {task}', ['task' => $taskName]); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function process() |
|
67
|
|
|
{ |
|
68
|
|
|
if (!is_subclass_of($this->TaskClass, BuildTask::class)) { |
|
|
|
|
|
|
69
|
|
|
throw new \LogicException($this->TaskClass . ' is not a build task'); |
|
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
$task = Injector::inst()->create($this->TaskClass); |
|
|
|
|
|
|
73
|
|
|
if (!$task->isEnabled()) { |
|
74
|
|
|
throw new \LogicException($this->TaskClass . ' is not enabled'); |
|
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$getVars = []; |
|
78
|
|
|
parse_str($this->QueryString, $getVars); |
|
|
|
|
|
|
79
|
|
|
$request = new HTTPRequest('GET', '/', $getVars); |
|
|
|
|
|
|
80
|
|
|
$task->run($request); |
|
81
|
|
|
|
|
82
|
|
|
$this->currentStep = 1; |
|
83
|
|
|
$this->isComplete = true; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.