|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @license MIT |
|
7
|
|
|
* @copyright 2013 - 2019 Cross Solution <http://cross-solution.de> |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** */ |
|
11
|
|
|
namespace Core\Queue; |
|
12
|
|
|
|
|
13
|
|
|
use Core\Queue\Exception\AbstractJobException; |
|
14
|
|
|
use Core\Queue\Exception\FatalJobException; |
|
15
|
|
|
use SlmQueue\Job\AbstractJob; |
|
16
|
|
|
use SlmQueue\Job\JobPluginManager; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* ${CARET} |
|
20
|
|
|
* |
|
21
|
|
|
* @author Mathias Gelhausen <[email protected]> |
|
22
|
|
|
* @todo write test |
|
23
|
|
|
*/ |
|
24
|
|
|
class LazyJob extends AbstractJob |
|
25
|
|
|
{ |
|
26
|
|
|
protected $container; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct(JobPluginManager $container, array $options = null) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->container = $container; |
|
31
|
|
|
if (isset($options['name'])) { |
|
32
|
|
|
$this->setServiceName($options['name']); |
|
33
|
|
|
} |
|
34
|
|
|
if (isset($options['options'])) { |
|
35
|
|
|
$this->setServiceOptions($options['options']); |
|
36
|
|
|
} |
|
37
|
|
|
if (isset($options['content'])) { |
|
38
|
|
|
$this->setContent($options['content']); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function setServiceName($name) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->setMetadata('service_name', $name); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function getServiceName() |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->getMetadata('service_name'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function setServiceOptions($options) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->setMetadata('service_options', $options); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getServiceOptions() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->getMetadata('service_options'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function execute() |
|
63
|
|
|
{ |
|
64
|
|
|
$service = $this->getServiceName(); |
|
65
|
|
|
|
|
66
|
|
|
if ($this->container->has($service)) { |
|
67
|
|
|
$job = $this->container->get($service, $this->getServiceOptions()); |
|
68
|
|
|
|
|
69
|
|
|
} elseif (class_exists($service)) { |
|
70
|
|
|
$options = $this->getServiceOptions(); |
|
71
|
|
|
$job = $options ? new $service(...$options) : new $service; |
|
72
|
|
|
|
|
73
|
|
|
} else { |
|
74
|
|
|
throw new FatalJobException('A job with name "' . $service . '" could not be created.'); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$job->setContent($this->getContent()); |
|
78
|
|
|
if ($job instanceOf LazyJobWrapperAwareInterface) { |
|
|
|
|
|
|
79
|
|
|
$job->setWrapper($this); |
|
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
return $job->execute(); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths