|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of php-task library. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) php-task |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Task\TaskBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
15
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Defines configuration for php-task library. |
|
19
|
|
|
*/ |
|
20
|
|
|
class Configuration implements ConfigurationInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var string[] |
|
24
|
|
|
*/ |
|
25
|
|
|
private $lockingStorageAliases = []; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param \string[] $lockingStorageAliases |
|
29
|
|
|
*/ |
|
30
|
|
|
public function __construct(array $lockingStorageAliases) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->lockingStorageAliases = $lockingStorageAliases; |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
|
|
public function getConfigTreeBuilder() |
|
39
|
|
|
{ |
|
40
|
|
|
$treeBuilder = new TreeBuilder(); |
|
41
|
|
|
|
|
42
|
|
|
$treeBuilder->root('task') |
|
|
|
|
|
|
43
|
|
|
->children() |
|
44
|
|
|
->enumNode('storage')->values(['array', 'doctrine'])->defaultValue('doctrine')->end() |
|
45
|
|
|
->arrayNode('adapters') |
|
46
|
|
|
->addDefaultsIfNotSet() |
|
47
|
|
|
->children() |
|
48
|
|
|
->arrayNode('doctrine') |
|
49
|
|
|
->addDefaultsIfNotSet() |
|
50
|
|
|
->children() |
|
51
|
|
|
->booleanNode('clear')->defaultTrue()->end() |
|
52
|
|
|
->end() |
|
53
|
|
|
->end() |
|
54
|
|
|
->end() |
|
55
|
|
|
->end() |
|
56
|
|
|
->arrayNode('run') |
|
57
|
|
|
->addDefaultsIfNotSet() |
|
58
|
|
|
->children() |
|
59
|
|
|
->enumNode('mode')->values(['off', 'listener'])->defaultValue('off')->end() |
|
60
|
|
|
->end() |
|
61
|
|
|
->end() |
|
62
|
|
|
->arrayNode('locking') |
|
63
|
|
|
->canBeEnabled() |
|
64
|
|
|
->addDefaultsIfNotSet() |
|
65
|
|
|
->children() |
|
66
|
|
|
->enumNode('storage') |
|
67
|
|
|
->values(array_keys($this->lockingStorageAliases)) |
|
68
|
|
|
->defaultValue('file') |
|
69
|
|
|
->end() |
|
70
|
|
|
->integerNode('ttl')->defaultValue(600)->end() |
|
71
|
|
|
->arrayNode('storages') |
|
72
|
|
|
->addDefaultsIfNotSet() |
|
73
|
|
|
->children() |
|
74
|
|
|
->arrayNode('file') |
|
75
|
|
|
->addDefaultsIfNotSet() |
|
76
|
|
|
->children() |
|
77
|
|
|
->scalarNode('directory')->defaultValue('%kernel.cache_dir%/tasks')->end() |
|
78
|
|
|
->end() |
|
79
|
|
|
->end() |
|
80
|
|
|
->end() |
|
81
|
|
|
->end() |
|
82
|
|
|
->end() |
|
83
|
|
|
->end() |
|
84
|
|
|
->arrayNode('executor') |
|
85
|
|
|
->addDefaultsIfNotSet() |
|
86
|
|
|
->children() |
|
87
|
|
|
->enumNode('type')->values(['inside', 'separate'])->defaultValue('inside')->end() |
|
88
|
|
|
->arrayNode('separate') |
|
89
|
|
|
->addDefaultsIfNotSet() |
|
90
|
|
|
->children() |
|
91
|
|
|
->scalarNode('console_path')->defaultValue('%kernel.root_dir%/../bin/console')->end() |
|
92
|
|
|
->floatNode('process_timeout')->defaultNull()->end() |
|
93
|
|
|
->end() |
|
94
|
|
|
->end() |
|
95
|
|
|
->end() |
|
96
|
|
|
->end() |
|
97
|
|
|
->arrayNode('system_tasks') |
|
98
|
|
|
->prototype('array') |
|
99
|
|
|
->children() |
|
100
|
|
|
->booleanNode('enabled')->defaultTrue()->end() |
|
101
|
|
|
->scalarNode('handler_class')->end() |
|
102
|
|
|
->variableNode('workload')->defaultNull()->end() |
|
103
|
|
|
->scalarNode('cron_expression')->end() |
|
104
|
|
|
->end() |
|
105
|
|
|
->end() |
|
106
|
|
|
->end() |
|
107
|
|
|
->end(); |
|
108
|
|
|
|
|
109
|
|
|
return $treeBuilder; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Returns id for given storage-alias. |
|
114
|
|
|
* |
|
115
|
|
|
* @param string $alias |
|
116
|
|
|
* |
|
117
|
|
|
* @return string |
|
118
|
|
|
*/ |
|
119
|
|
|
public function getLockingStorageId($alias) |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->lockingStorageAliases[$alias]; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..