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
|
|
|
* @param DataObject $node |
|
|
|
|
23
|
|
|
*/ |
24
|
|
|
public function __construct($taskClass = null, $queryString = null) { |
25
|
|
|
if ($taskClass) { |
26
|
|
|
$this->TaskClass = $taskClass; |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
if ($queryString) { |
30
|
|
|
$this->QueryString = $queryString; |
|
|
|
|
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
$this->currentStep = 0; |
34
|
|
|
$this->totalSteps = 1; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param string (default: Object) |
39
|
|
|
* @return DataObject |
40
|
|
|
*/ |
41
|
|
|
protected function getObject($name = 'SilverStripe\\Core\\Object') { |
42
|
|
|
return DataObject::get_by_id($this->TargetClass, $this->TargetID); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getJobType() { |
49
|
|
|
return QueuedJob::QUEUED; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
|
|
public function getTitle() { |
56
|
|
|
$taskName = $this->QueryString ? ($this->TaskClass . '?' . $this->QueryString) : $this->TaskClass; |
|
|
|
|
57
|
|
|
return _t('RunBuildTaskJob.JOB_TITLE', 'Run BuildTask {task}', array('task' => $taskName)); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function process() { |
61
|
|
|
if (!is_subclass_of($this->TaskClass, BuildTask::class)) { |
|
|
|
|
62
|
|
|
throw new \LogicException($this->TaskClass . ' is not a build task'); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$task = Injector::inst()->create($this->TaskClass); |
|
|
|
|
66
|
|
|
if (!$task->isEnabled()) { |
67
|
|
|
throw new \LogicException($this->TaskClass . ' is not enabled'); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$getVars = array(); |
71
|
|
|
parse_str($this->QueryString, $getVars); |
|
|
|
|
72
|
|
|
$request = new HTTPRequest('GET', '/', $getVars); |
|
|
|
|
73
|
|
|
$task->run($request); |
74
|
|
|
|
75
|
|
|
$this->currentStep = 1; |
76
|
|
|
$this->isComplete = true; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
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
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.