1 | <?php |
||
23 | class Manager implements ManagerInterface |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * @var \HDNET\Importr\Domain\Repository\ImportRepository |
||
28 | */ |
||
29 | protected $importRepository; |
||
30 | |||
31 | /** |
||
32 | * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher |
||
33 | */ |
||
34 | protected $signalSlotDispatcher; |
||
35 | |||
36 | /** |
||
37 | * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager |
||
38 | */ |
||
39 | protected $persistenceManager; |
||
40 | |||
41 | /** |
||
42 | * @var \TYPO3\CMS\Extbase\Object\ObjectManager |
||
43 | */ |
||
44 | protected $objectManager; |
||
45 | |||
46 | /** |
||
47 | * @var \HDNET\Importr\Processor\Configuration |
||
48 | */ |
||
49 | protected $configuration; |
||
50 | |||
51 | /** |
||
52 | * @var \HDNET\Importr\Processor\Resource |
||
53 | */ |
||
54 | protected $resource; |
||
55 | |||
56 | 2 | public function __construct( |
|
57 | ImportRepository $importRepository, |
||
58 | Dispatcher $signalSlotDispatcher, |
||
59 | PersistenceManager $persistenceManager, |
||
60 | ObjectManager $objectManager, |
||
61 | Configuration $configuration, |
||
62 | Resource $resource |
||
63 | ) { |
||
64 | 2 | $this->importRepository = $importRepository; |
|
65 | 2 | $this->signalSlotDispatcher = $signalSlotDispatcher; |
|
66 | 2 | $this->persistenceManager = $persistenceManager; |
|
67 | 2 | $this->objectManager = $objectManager; |
|
68 | 2 | $this->configuration = $configuration; |
|
69 | 2 | $this->resource = $resource; |
|
70 | 2 | } |
|
71 | |||
72 | /** |
||
73 | * Update Interval |
||
74 | * |
||
75 | * @var int |
||
76 | */ |
||
77 | protected $updateInterval = 1; |
||
78 | |||
79 | /** |
||
80 | * run the Importr |
||
81 | */ |
||
82 | 1 | public function runImports() |
|
83 | { |
||
84 | try { |
||
85 | 1 | $imports = $this->importRepository->findWorkQueue(); |
|
86 | 1 | foreach ($imports as $import) { |
|
87 | 1 | $this->runImport($import); |
|
88 | } |
||
89 | } catch (ReinitializeException $exc) { |
||
90 | $this->runImports(); |
||
91 | } |
||
92 | 1 | } |
|
93 | |||
94 | /** |
||
95 | * Get the preview |
||
96 | * |
||
97 | * @param string $filepath |
||
98 | * @param \HDNET\Importr\Domain\Model\Strategy $strategy |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | 1 | public function getPreview(Strategy $strategy, $filepath) |
|
103 | { |
||
104 | 1 | $data = []; |
|
105 | 1 | $resources = $this->initializeResources($strategy, $filepath); |
|
106 | 1 | foreach ($resources as $resource) { |
|
107 | /** @var \HDNET\Importr\Service\Resources\ResourceInterface $resource */ |
||
108 | // Resourcen Object anhand der Datei auswählen |
||
109 | 1 | if (\preg_match($resource->getFilepathExpression(), $filepath)) { |
|
110 | // Resource "benutzen" |
||
111 | 1 | $resource->parseResource(); |
|
112 | // Durchlauf starten |
||
113 | 1 | for ($pointer = 0; $pointer <= 20; $pointer++) { |
|
114 | 1 | if ($resource->getEntry($pointer)) { |
|
115 | 1 | $data[] = $resource->getEntry($pointer); |
|
116 | } |
||
117 | } |
||
118 | 1 | break; |
|
119 | } |
||
120 | } |
||
121 | 1 | return $data; |
|
122 | } |
||
123 | |||
124 | /** |
||
125 | * Magic Runner |
||
126 | * |
||
127 | * @param \HDNET\Importr\Domain\Model\Import $import |
||
128 | */ |
||
129 | protected function runImport(Import $import) |
||
148 | |||
149 | /** |
||
150 | * @param \HDNET\Importr\Domain\Model\Import $import |
||
151 | * |
||
152 | * @return array |
||
153 | */ |
||
154 | protected function initializeResourcesByImport(Import $import) |
||
158 | |||
159 | /** |
||
160 | * @param \HDNET\Importr\Domain\Model\Strategy $strategy |
||
161 | * @param string $filepath |
||
162 | * |
||
163 | * @return array |
||
164 | */ |
||
165 | 1 | protected function initializeResources(Strategy $strategy, $filepath) |
|
166 | { |
||
167 | 1 | $resources = []; |
|
168 | 1 | $resourceConfiguration = $strategy->getResources(); |
|
169 | 1 | foreach ($resourceConfiguration as $resource => $configuration) { |
|
170 | 1 | $object = $this->objectManager->get($resource); |
|
|
|||
171 | 1 | $object->start($strategy, $filepath); |
|
172 | 1 | $object->setConfiguration($configuration); |
|
173 | 1 | $resources[$resource] = $object; |
|
174 | } |
||
175 | 1 | return $resources; |
|
176 | } |
||
177 | |||
178 | /** |
||
179 | * @param \HDNET\Importr\Domain\Model\Import $import |
||
180 | * |
||
181 | * @return array |
||
182 | */ |
||
183 | protected function initializeTargets(Import $import) |
||
189 | |||
190 | protected function addTargets(array $targetConfiguration, Import $import, array $targets = []): array |
||
205 | |||
206 | /** |
||
207 | * @param \HDNET\Importr\Domain\Model\Import $import |
||
208 | */ |
||
209 | protected function teardownTargets(Import $import) |
||
215 | |||
216 | protected function endTargets(array $targetConfiguration, Import $import): void |
||
229 | |||
230 | /** |
||
231 | * @param int $interval |
||
232 | */ |
||
233 | 1 | public function setUpdateInterval($interval) |
|
237 | |||
238 | /** |
||
239 | * @return int |
||
240 | */ |
||
241 | 1 | public function getUpdateInterval() |
|
245 | |||
246 | /** |
||
247 | * @param string $name |
||
248 | * @param Import $import |
||
249 | */ |
||
250 | protected function emitSignal($name, Import $import) |
||
258 | } |
||
259 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.