1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace Xervice\Processor\Business; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Xervice\ArrayHandler\Business\ArrayHandlerFacade; |
8
|
|
|
use Xervice\ArrayHandler\Dependency\FieldHandlerPluginInterface; |
9
|
|
|
use Xervice\Core\Business\Model\Factory\AbstractBusinessFactory; |
10
|
|
|
use Xervice\Processor\Business\Model\Hydrator\DataHydrator; |
11
|
|
|
use Xervice\Processor\Business\Model\Hydrator\DataHydratorInterface; |
12
|
|
|
use Xervice\Processor\Business\Model\Processor\ProcessConfigurationPluginCollection; |
13
|
|
|
use Xervice\Processor\Business\Model\Processor\Processor; |
14
|
|
|
use Xervice\Processor\Business\Model\Processor\ProcessorInterface; |
15
|
|
|
use Xervice\Processor\Business\Model\Translator\DataTranslator; |
16
|
|
|
use Xervice\Processor\Business\Model\Translator\DataTranslatorInterface; |
17
|
|
|
use Xervice\Processor\Communication\Plugin\HydratorFieldHandlerPlugin; |
18
|
|
|
use Xervice\Processor\Communication\Plugin\TranslatorFieldHandlerPlugin; |
19
|
|
|
use Xervice\Processor\ProcessorDependencyProvider; |
20
|
|
|
use Xervice\Validator\Business\ValidatorFacade; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @method \Xervice\Processor\ProcessorConfig getConfig() |
24
|
|
|
*/ |
25
|
|
|
class ProcessorBusinessFactory extends AbstractBusinessFactory |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @return \Xervice\Processor\Business\Model\Processor\ProcessorInterface |
29
|
|
|
*/ |
30
|
3 |
|
public function createProcessor(): ProcessorInterface |
31
|
|
|
{ |
32
|
3 |
|
return new Processor( |
33
|
3 |
|
$this->getProcessConfigurationPluginCollection(), |
34
|
3 |
|
$this->getValidatorFacade(), |
35
|
3 |
|
$this->createDataHydrator(), |
36
|
3 |
|
$this->createDataTranslator() |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return \Xervice\Processor\Business\Model\Translator\DataTranslatorInterface |
42
|
|
|
*/ |
43
|
3 |
|
public function createDataTranslator(): DataTranslatorInterface |
44
|
|
|
{ |
45
|
3 |
|
return new DataTranslator( |
46
|
3 |
|
$this->getArrayHandlerFacade(), |
47
|
3 |
|
$this->createTranslatorFieldHandlerPlugin() |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return \Xervice\Processor\Business\Model\Hydrator\DataHydratorInterface |
53
|
|
|
*/ |
54
|
3 |
|
public function createDataHydrator(): DataHydratorInterface |
55
|
|
|
{ |
56
|
3 |
|
return new DataHydrator( |
57
|
3 |
|
$this->getArrayHandlerFacade(), |
58
|
3 |
|
$this->createHydratorFieldHandlerPlugin() |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return \Xervice\ArrayHandler\Dependency\FieldHandlerPluginInterface |
64
|
|
|
*/ |
65
|
3 |
|
public function createTranslatorFieldHandlerPlugin(): FieldHandlerPluginInterface |
66
|
|
|
{ |
67
|
3 |
|
return new TranslatorFieldHandlerPlugin( |
68
|
3 |
|
$this->getTranslatorFunctions() |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return \Xervice\ArrayHandler\Dependency\FieldHandlerPluginInterface |
74
|
|
|
*/ |
75
|
3 |
|
public function createHydratorFieldHandlerPlugin(): FieldHandlerPluginInterface |
76
|
|
|
{ |
77
|
3 |
|
return new HydratorFieldHandlerPlugin(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return \Xervice\Processor\Business\Model\Processor\ProcessConfigurationPluginCollection |
82
|
|
|
*/ |
83
|
3 |
|
public function getProcessConfigurationPluginCollection(): ProcessConfigurationPluginCollection |
84
|
|
|
{ |
85
|
3 |
|
return $this->getDependency(ProcessorDependencyProvider::PROCESS_PLUGINS); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return \Xervice\Processor\Business\Model\Translator\TranslatorInterface[] |
90
|
|
|
*/ |
91
|
3 |
|
public function getTranslatorFunctions(): array |
92
|
|
|
{ |
93
|
3 |
|
return $this->getDependency(ProcessorDependencyProvider::TRANSLATOR_FUNCTIONS); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return \Xervice\Validator\Business\ValidatorFacade |
98
|
|
|
*/ |
99
|
3 |
|
public function getValidatorFacade(): ValidatorFacade |
100
|
|
|
{ |
101
|
3 |
|
return $this->getDependency(ProcessorDependencyProvider::VALIDATOR_FACADE); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return \Xervice\ArrayHandler\Business\ArrayHandlerFacade |
106
|
|
|
*/ |
107
|
3 |
|
public function getArrayHandlerFacade(): ArrayHandlerFacade |
108
|
|
|
{ |
109
|
3 |
|
return $this->getDependency(ProcessorDependencyProvider::ARRAY_HANDLER_FACADE); |
110
|
|
|
} |
111
|
|
|
} |