1 | <?php |
||
17 | class Configuration |
||
18 | { |
||
19 | /** |
||
20 | * @var Dispatcher |
||
21 | */ |
||
22 | protected $dispatcher; |
||
23 | |||
24 | /** |
||
25 | * @var StrategyRepository |
||
26 | */ |
||
27 | protected $strategyRepository; |
||
28 | |||
29 | /** |
||
30 | * @var ImportServiceInterface |
||
31 | */ |
||
32 | protected $importService; |
||
33 | |||
34 | /** |
||
35 | * Configuration constructor. |
||
36 | * |
||
37 | * @param Dispatcher $dispatcher |
||
38 | * @param StrategyRepository $strategyRepository |
||
39 | * @param ImportServiceInterface $importService |
||
40 | */ |
||
41 | 6 | public function __construct(Dispatcher $dispatcher, StrategyRepository $strategyRepository, ImportServiceInterface $importService) |
|
42 | { |
||
43 | 6 | $this->dispatcher = $dispatcher; |
|
44 | 6 | $this->strategyRepository = $strategyRepository; |
|
45 | 6 | $this->importService = $importService; |
|
46 | 6 | } |
|
47 | |||
48 | /** |
||
49 | * @param array $configuration |
||
50 | * @param ManagerInterface $manager |
||
51 | * @param mixed $filter |
||
52 | * |
||
53 | * @throws ReinitializeException |
||
54 | * @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException |
||
55 | * @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotReturnException |
||
56 | */ |
||
57 | 5 | public function process(array $configuration, ManagerInterface $manager, $filter = null) |
|
58 | { |
||
59 | 5 | if ($filter === null) { |
|
60 | 3 | $this->processInner($configuration, $manager); |
|
61 | 2 | } elseif ($this->canProcess($configuration, $filter)) { |
|
62 | 1 | $this->processInner($configuration[$filter], $manager); |
|
63 | } |
||
64 | 4 | } |
|
65 | |||
66 | /** |
||
67 | * @param array $configuration |
||
68 | * @param string $name |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | 3 | public function canProcess(array $configuration, $name) |
|
73 | { |
||
74 | 3 | return isset($configuration[$name]) && \is_array($configuration[$name]); |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * @param array $configuration |
||
79 | * @param ManagerInterface $manager |
||
80 | * |
||
81 | * @throws ReinitializeException |
||
82 | * @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException |
||
83 | * @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotReturnException |
||
84 | */ |
||
85 | 4 | protected function processInner(array $configuration, ManagerInterface $manager) |
|
86 | { |
||
87 | 4 | $this->emitSignal('preParseConfiguration', $configuration); |
|
88 | try { |
||
89 | 4 | $this->updateInterval($configuration, $manager) |
|
90 | 4 | ->createImport($configuration) |
|
91 | 4 | ->reinitializeScheduler($configuration); |
|
92 | |||
93 | 3 | $this->emitSignal('postParseConfiguration', $configuration); |
|
94 | 1 | } catch (ReinitializeException $exception) { |
|
95 | 1 | $this->emitSignal('postParseConfiguration', $configuration); |
|
96 | 1 | throw $exception; |
|
97 | } |
||
98 | 3 | } |
|
99 | |||
100 | /** |
||
101 | * @param string $name |
||
102 | * @param array $configuration |
||
103 | * |
||
104 | * @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException |
||
105 | * @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotReturnException |
||
106 | */ |
||
107 | 4 | protected function emitSignal($name, array &$configuration) |
|
115 | |||
116 | /** |
||
117 | * @param array $configuration |
||
118 | * @param ManagerInterface $manager |
||
119 | * @return $this |
||
120 | */ |
||
121 | 4 | protected function updateInterval(array $configuration, ManagerInterface $manager) |
|
129 | |||
130 | /** |
||
131 | * @param array $configuration |
||
132 | * @return $this |
||
133 | * @throws ReinitializeException |
||
134 | */ |
||
135 | 4 | protected function reinitializeScheduler(array $configuration) |
|
143 | |||
144 | /** |
||
145 | * @param array $configuration |
||
146 | * @return $this |
||
147 | */ |
||
148 | 4 | protected function createImport(array $configuration) |
|
165 | } |
||
166 |