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
|
30 |
|
public function __construct(array $lockingStorageAliases) |
31
|
|
|
{ |
32
|
30 |
|
$this->lockingStorageAliases = $lockingStorageAliases; |
|
|
|
|
33
|
30 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* {@inheritdoc} |
37
|
|
|
*/ |
38
|
30 |
|
public function getConfigTreeBuilder() |
39
|
|
|
{ |
40
|
30 |
|
$treeBuilder = new TreeBuilder(); |
41
|
|
|
|
42
|
30 |
|
$treeBuilder->root('task') |
43
|
30 |
|
->children() |
44
|
30 |
|
->enumNode('storage')->values(['array', 'doctrine'])->defaultValue('doctrine')->end() |
45
|
30 |
|
->arrayNode('adapters') |
46
|
30 |
|
->addDefaultsIfNotSet() |
47
|
30 |
|
->children() |
48
|
30 |
|
->arrayNode('doctrine') |
49
|
30 |
|
->addDefaultsIfNotSet() |
50
|
30 |
|
->children() |
51
|
30 |
|
->booleanNode('clear')->defaultTrue()->end() |
52
|
30 |
|
->end() |
53
|
30 |
|
->end() |
54
|
30 |
|
->end() |
55
|
30 |
|
->end() |
56
|
30 |
|
->arrayNode('run') |
57
|
30 |
|
->addDefaultsIfNotSet() |
58
|
30 |
|
->children() |
59
|
30 |
|
->enumNode('mode')->values(['off', 'listener'])->defaultValue('off')->end() |
60
|
30 |
|
->end() |
61
|
30 |
|
->end() |
62
|
30 |
|
->arrayNode('locking') |
63
|
30 |
|
->canBeEnabled() |
64
|
30 |
|
->addDefaultsIfNotSet() |
65
|
30 |
|
->children() |
66
|
30 |
|
->enumNode('storage') |
67
|
30 |
|
->values(array_keys($this->lockingStorageAliases)) |
68
|
30 |
|
->defaultValue('file') |
69
|
30 |
|
->end() |
70
|
30 |
|
->integerNode('ttl')->defaultValue(600)->end() |
71
|
30 |
|
->arrayNode('storages') |
72
|
30 |
|
->addDefaultsIfNotSet() |
73
|
30 |
|
->children() |
74
|
30 |
|
->arrayNode('file') |
75
|
30 |
|
->addDefaultsIfNotSet() |
76
|
30 |
|
->children() |
77
|
30 |
|
->scalarNode('directory')->defaultValue('%kernel.cache_dir%/tasks')->end() |
78
|
30 |
|
->end() |
79
|
30 |
|
->end() |
80
|
30 |
|
->end() |
81
|
30 |
|
->end() |
82
|
30 |
|
->end() |
83
|
30 |
|
->end() |
84
|
30 |
|
->arrayNode('system_tasks') |
85
|
30 |
|
->prototype('array') |
86
|
30 |
|
->children() |
87
|
30 |
|
->booleanNode('enabled')->defaultTrue()->end() |
88
|
30 |
|
->scalarNode('handler_class')->end() |
89
|
30 |
|
->variableNode('workload')->defaultNull()->end() |
90
|
30 |
|
->scalarNode('cron_expression')->end() |
91
|
30 |
|
->end() |
92
|
30 |
|
->end() |
93
|
30 |
|
->end() |
94
|
30 |
|
->end(); |
95
|
|
|
|
96
|
30 |
|
return $treeBuilder; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Returns id for given storage-alias. |
101
|
|
|
* |
102
|
|
|
* @param string $alias |
103
|
|
|
* |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
30 |
|
public function getLockingStorageId($alias) |
107
|
|
|
{ |
108
|
30 |
|
return $this->lockingStorageAliases[$alias]; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
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..