|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Xervice\Processor; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use Xervice\Core\Business\Model\Dependency\Provider\AbstractDependencyProvider; |
|
8
|
|
|
use Xervice\Core\Business\Model\Dependency\DependencyContainerInterface; |
|
9
|
|
|
use Xervice\Processor\Business\Model\Processor\ProcessConfigurationPluginCollection; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @method \Xervice\Core\Locator\Locator getLocator() |
|
13
|
|
|
*/ |
|
14
|
|
|
class ProcessorDependencyProvider extends AbstractDependencyProvider |
|
15
|
|
|
{ |
|
16
|
|
|
public const PROCESS_PLUGINS = 'processor.process.plugins'; |
|
17
|
|
|
public const TRANSLATOR_FUNCTIONS = 'processor.translator.function'; |
|
18
|
|
|
public const VALIDATOR_FACADE = 'processor.validator.facade'; |
|
19
|
|
|
public const ARRAY_HANDLER_FACADE = 'processor.array.handler.facade'; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
23
|
|
|
* |
|
24
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
25
|
|
|
*/ |
|
26
|
1 |
|
public function handleDependencies(DependencyContainerInterface $container): DependencyContainerInterface |
|
27
|
|
|
{ |
|
28
|
1 |
|
$container = $this->addProcessConfigurationPluginCollection($container); |
|
29
|
1 |
|
$container = $this->addTranslatorFunctions($container); |
|
30
|
1 |
|
$container = $this->addValidatorFacade($container); |
|
31
|
1 |
|
$container = $this->addArrayHandlerFacade($container); |
|
32
|
|
|
|
|
33
|
1 |
|
return $container; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
38
|
|
|
* |
|
39
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
40
|
|
|
*/ |
|
41
|
1 |
|
protected function addProcessConfigurationPluginCollection(DependencyContainerInterface $container): DependencyContainerInterface |
|
42
|
|
|
{ |
|
43
|
|
|
$container[static::PROCESS_PLUGINS] = function (DependencyContainerInterface $container) { |
|
|
|
|
|
|
44
|
1 |
|
return new ProcessConfigurationPluginCollection( |
|
45
|
1 |
|
$this->getProcessConfigurationPlugins() |
|
46
|
|
|
); |
|
47
|
|
|
}; |
|
48
|
1 |
|
return $container; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return \Xervice\Processor\Business\Dependency\ProcessConfigurationPluginInterface[] |
|
53
|
|
|
*/ |
|
54
|
|
|
protected function getProcessConfigurationPlugins(): array |
|
55
|
|
|
{ |
|
56
|
|
|
return []; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return \Xervice\Processor\Business\Model\Translator\TranslatorInterface[] |
|
61
|
|
|
*/ |
|
62
|
|
|
protected function getTranslatorFunctions(): array |
|
63
|
|
|
{ |
|
64
|
|
|
return []; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
69
|
|
|
* |
|
70
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
71
|
|
|
*/ |
|
72
|
1 |
|
protected function addValidatorFacade(DependencyContainerInterface $container): DependencyContainerInterface |
|
73
|
|
|
{ |
|
74
|
|
|
$container[static::VALIDATOR_FACADE] = function (DependencyContainerInterface $container) { |
|
75
|
1 |
|
return $container->getLocator()->validator()->facade(); |
|
|
|
|
|
|
76
|
|
|
}; |
|
77
|
|
|
|
|
78
|
1 |
|
return $container; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
83
|
|
|
* |
|
84
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
85
|
|
|
*/ |
|
86
|
1 |
|
protected function addArrayHandlerFacade(DependencyContainerInterface $container): DependencyContainerInterface |
|
87
|
|
|
{ |
|
88
|
|
|
$container[static::ARRAY_HANDLER_FACADE] = function (DependencyContainerInterface $container) { |
|
89
|
1 |
|
return $container->getLocator()->arrayHandler()->facade(); |
|
90
|
|
|
}; |
|
91
|
|
|
|
|
92
|
1 |
|
return $container; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
97
|
|
|
* |
|
98
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
99
|
|
|
*/ |
|
100
|
1 |
|
protected function addTranslatorFunctions(DependencyContainerInterface $container): DependencyContainerInterface |
|
101
|
|
|
{ |
|
102
|
|
|
$container[static::TRANSLATOR_FUNCTIONS] = function (DependencyContainerInterface $container) { |
|
|
|
|
|
|
103
|
1 |
|
return $this->getTranslatorFunctions(); |
|
104
|
|
|
}; |
|
105
|
|
|
|
|
106
|
1 |
|
return $container; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.