|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Configuration\Jms\Configuration |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/techdivision/import-configuration-jms |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Configuration\Jms; |
|
22
|
|
|
|
|
23
|
|
|
use Psr\Log\LogLevel; |
|
24
|
|
|
use JMS\Serializer\Annotation\Type; |
|
25
|
|
|
use JMS\Serializer\Annotation\Exclude; |
|
26
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
|
27
|
|
|
use JMS\Serializer\Annotation\PostDeserialize; |
|
28
|
|
|
use JMS\Serializer\Annotation\ExclusionPolicy; |
|
29
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
30
|
|
|
use TechDivision\Import\ConfigurationInterface; |
|
31
|
|
|
use TechDivision\Import\Configuration\DatabaseConfigurationInterface; |
|
32
|
|
|
use TechDivision\Import\Configuration\Jms\Configuration\Operation; |
|
33
|
|
|
use TechDivision\Import\Configuration\Jms\Configuration\ParamsTrait; |
|
34
|
|
|
use TechDivision\Import\Configuration\Jms\Configuration\CsvTrait; |
|
35
|
|
|
use TechDivision\Import\Configuration\Jms\Configuration\ListenersTrait; |
|
36
|
|
|
use TechDivision\Import\Configuration\ListenerAwareConfigurationInterface; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* A simple JMS based configuration implementation. |
|
40
|
|
|
* |
|
41
|
|
|
* @author Tim Wagner <[email protected]> |
|
42
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
43
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
44
|
|
|
* @link https://github.com/techdivision/import-configuration-jms |
|
45
|
|
|
* @link http://www.techdivision.com |
|
46
|
|
|
* |
|
47
|
|
|
* @ExclusionPolicy("none") |
|
48
|
|
|
*/ |
|
49
|
|
|
class Configuration implements ConfigurationInterface, ListenerAwareConfigurationInterface |
|
50
|
|
|
{ |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* The default PID filename to use. |
|
54
|
|
|
* |
|
55
|
|
|
* @var string |
|
56
|
|
|
*/ |
|
57
|
|
|
const PID_FILENAME = 'importer.pid'; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Trait that provides CSV configuration functionality. |
|
61
|
|
|
* |
|
62
|
|
|
* @var \TechDivision\Import\Configuration\Jms\Configuration\CsvTrait |
|
63
|
|
|
*/ |
|
64
|
|
|
use CsvTrait; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Trait that provides CSV configuration functionality. |
|
68
|
|
|
* |
|
69
|
|
|
* @var \TechDivision\Import\Configuration\Jms\Configuration\ParamsTrait |
|
70
|
|
|
*/ |
|
71
|
|
|
use ParamsTrait; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Trait that provides CSV configuration functionality. |
|
75
|
|
|
* |
|
76
|
|
|
* @var \TechDivision\Import\Configuration\Jms\Configuration\ListenersTrait |
|
77
|
|
|
*/ |
|
78
|
|
|
use ListenersTrait; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* The array with the available database types. |
|
82
|
|
|
* |
|
83
|
|
|
* @var array |
|
84
|
|
|
* @Exclude |
|
85
|
|
|
*/ |
|
86
|
|
|
protected $availableDatabaseTypes = array( |
|
87
|
|
|
DatabaseConfigurationInterface::TYPE_MYSQL, |
|
88
|
|
|
DatabaseConfigurationInterface::TYPE_REDIS |
|
89
|
|
|
); |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Mapping for boolean values passed on the console. |
|
93
|
|
|
* |
|
94
|
|
|
* @var array |
|
95
|
|
|
* @Exclude |
|
96
|
|
|
*/ |
|
97
|
|
|
protected $booleanMapping = array( |
|
98
|
|
|
'true' => true, |
|
99
|
|
|
'false' => false, |
|
100
|
|
|
'1' => true, |
|
101
|
|
|
'0' => false, |
|
102
|
|
|
'on' => true, |
|
103
|
|
|
'off' => false |
|
104
|
|
|
); |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* The serial that will be passed as commandline option (can not be specified in configuration file). |
|
108
|
|
|
* |
|
109
|
|
|
* @var string |
|
110
|
|
|
* @Exclude |
|
111
|
|
|
*/ |
|
112
|
|
|
protected $serial; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* The application's unique DI identifier. |
|
116
|
|
|
* |
|
117
|
|
|
* @var string |
|
118
|
|
|
* @Type("string") |
|
119
|
|
|
* @SerializedName("id") |
|
120
|
|
|
*/ |
|
121
|
|
|
protected $id; |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* The system name to use. |
|
125
|
|
|
* |
|
126
|
|
|
* @var string |
|
127
|
|
|
* @Type("string") |
|
128
|
|
|
* @SerializedName("system-name") |
|
129
|
|
|
*/ |
|
130
|
|
|
protected $systemName; |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* The operation name to use. |
|
134
|
|
|
* |
|
135
|
|
|
* @var string |
|
136
|
|
|
* @Type("string") |
|
137
|
|
|
* @SerializedName("operation-name") |
|
138
|
|
|
*/ |
|
139
|
|
|
protected $operationName; |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* The entity type code to use. |
|
143
|
|
|
* |
|
144
|
|
|
* @var string |
|
145
|
|
|
* @Type("string") |
|
146
|
|
|
* @SerializedName("entity-type-code") |
|
147
|
|
|
*/ |
|
148
|
|
|
protected $entityTypeCode; |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* The Magento installation directory. |
|
152
|
|
|
* |
|
153
|
|
|
* @var string |
|
154
|
|
|
* @Type("string") |
|
155
|
|
|
* @SerializedName("installation-dir") |
|
156
|
|
|
*/ |
|
157
|
|
|
protected $installationDir; |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* The source directory that has to be watched for new files. |
|
161
|
|
|
* |
|
162
|
|
|
* @var string |
|
163
|
|
|
* @Type("string") |
|
164
|
|
|
* @SerializedName("source-dir") |
|
165
|
|
|
*/ |
|
166
|
|
|
protected $sourceDir; |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* The target directory with the files that has been imported. |
|
170
|
|
|
* |
|
171
|
|
|
* @var string |
|
172
|
|
|
* @Type("string") |
|
173
|
|
|
* @SerializedName("target-dir") |
|
174
|
|
|
*/ |
|
175
|
|
|
protected $targetDir; |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* The Magento edition, EE or CE. |
|
179
|
|
|
* |
|
180
|
|
|
* @var string |
|
181
|
|
|
* @Type("string") |
|
182
|
|
|
* @SerializedName("magento-edition") |
|
183
|
|
|
*/ |
|
184
|
|
|
protected $magentoEdition = 'CE'; |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* The Magento version, e. g. 2.1.0. |
|
188
|
|
|
* |
|
189
|
|
|
* @var string |
|
190
|
|
|
* @Type("string") |
|
191
|
|
|
* @SerializedName("magento-version") |
|
192
|
|
|
*/ |
|
193
|
|
|
protected $magentoVersion = '2.1.2'; |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* ArrayCollection with the information of the configured databases. |
|
197
|
|
|
* |
|
198
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
|
199
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Database>") |
|
200
|
|
|
*/ |
|
201
|
|
|
protected $databases; |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* ArrayCollection with the information of the configured loggers. |
|
205
|
|
|
* |
|
206
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
|
207
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Logger>") |
|
208
|
|
|
*/ |
|
209
|
|
|
protected $loggers; |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* ArrayCollection with the information of the configured operations. |
|
213
|
|
|
* |
|
214
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
|
215
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Operation>") |
|
216
|
|
|
*/ |
|
217
|
|
|
protected $operations; |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* The subject's multiple field delimiter character for fields with multiple values, defaults to (,). |
|
221
|
|
|
* |
|
222
|
|
|
* @var string |
|
223
|
|
|
* @Type("string") |
|
224
|
|
|
* @SerializedName("multiple-field-delimiter") |
|
225
|
|
|
*/ |
|
226
|
|
|
protected $multipleFieldDelimiter = ','; |
|
227
|
|
|
|
|
228
|
|
|
/** |
|
229
|
|
|
* The subject's multiple value delimiter character for fields with multiple values, defaults to (|). |
|
230
|
|
|
* |
|
231
|
|
|
* @var string |
|
232
|
|
|
* @Type("string") |
|
233
|
|
|
* @SerializedName("multiple-value-delimiter") |
|
234
|
|
|
*/ |
|
235
|
|
|
protected $multipleValueDelimiter = '|'; |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* The flag to signal that the subject has to use the strict mode or not. |
|
239
|
|
|
* |
|
240
|
|
|
* @var boolean |
|
241
|
|
|
* @Type("boolean") |
|
242
|
|
|
* @SerializedName("strict-mode") |
|
243
|
|
|
*/ |
|
244
|
|
|
protected $strictMode; |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* The flag whether or not the import artefacts have to be archived. |
|
248
|
|
|
* |
|
249
|
|
|
* @var boolean |
|
250
|
|
|
* @Type("boolean") |
|
251
|
|
|
* @SerializedName("archive-artefacts") |
|
252
|
|
|
*/ |
|
253
|
|
|
protected $archiveArtefacts; |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* The directory where the archives will be stored. |
|
257
|
|
|
* |
|
258
|
|
|
* @var string |
|
259
|
|
|
* @Type("string") |
|
260
|
|
|
* @SerializedName("archive-dir") |
|
261
|
|
|
*/ |
|
262
|
|
|
protected $archiveDir; |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* The flag to signal that the subject has to use the debug mode or not. |
|
266
|
|
|
* |
|
267
|
|
|
* @var boolean |
|
268
|
|
|
* @Type("boolean") |
|
269
|
|
|
* @SerializedName("debug-mode") |
|
270
|
|
|
*/ |
|
271
|
|
|
protected $debugMode = false; |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* The log level to use (see Monolog documentation). |
|
275
|
|
|
* |
|
276
|
|
|
* @var string |
|
277
|
|
|
* @Type("string") |
|
278
|
|
|
* @SerializedName("log-level") |
|
279
|
|
|
*/ |
|
280
|
|
|
protected $logLevel = LogLevel::INFO; |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* The explicit DB ID to use. |
|
284
|
|
|
* |
|
285
|
|
|
* @var string |
|
286
|
|
|
* @Type("string") |
|
287
|
|
|
* @SerializedName("use-db-id") |
|
288
|
|
|
*/ |
|
289
|
|
|
protected $useDbId; |
|
290
|
|
|
|
|
291
|
|
|
/** |
|
292
|
|
|
* The explicit PID filename to use. |
|
293
|
|
|
* |
|
294
|
|
|
* @var string |
|
295
|
|
|
* @Type("string") |
|
296
|
|
|
* @SerializedName("pid-filename") |
|
297
|
|
|
*/ |
|
298
|
|
|
protected $pidFilename; |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* The collection with the paths to additional vendor directories. |
|
302
|
|
|
* |
|
303
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
|
304
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\VendorDir>") |
|
305
|
|
|
* @SerializedName("additional-vendor-dirs") |
|
306
|
|
|
*/ |
|
307
|
|
|
protected $additionalVendorDirs; |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* The array with the Magento Edition specific extension libraries. |
|
311
|
|
|
* |
|
312
|
|
|
* @var array |
|
313
|
|
|
* @Type("array") |
|
314
|
|
|
* @SerializedName("extension-libraries") |
|
315
|
|
|
*/ |
|
316
|
|
|
protected $extensionLibraries = array(); |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* The array with the custom header mappings. |
|
320
|
|
|
* |
|
321
|
|
|
* @var array |
|
322
|
|
|
* @Type("array") |
|
323
|
|
|
* @SerializedName("header-mappings") |
|
324
|
|
|
*/ |
|
325
|
|
|
protected $headerMappings = array(); |
|
326
|
|
|
|
|
327
|
|
|
/** |
|
328
|
|
|
* The array with the custom image types. |
|
329
|
|
|
* |
|
330
|
|
|
* @var array |
|
331
|
|
|
* @Type("array") |
|
332
|
|
|
* @SerializedName("image-types") |
|
333
|
|
|
*/ |
|
334
|
|
|
protected $imageTypes = array(); |
|
335
|
|
|
|
|
336
|
|
|
/** |
|
337
|
|
|
* The flag to signal that the import should be wrapped within a single transation or not. |
|
338
|
|
|
* |
|
339
|
|
|
* @var boolean |
|
340
|
|
|
* @Type("boolean") |
|
341
|
|
|
* @SerializedName("single-transaction") |
|
342
|
|
|
*/ |
|
343
|
|
|
protected $singleTransaction = false; |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* The flag to signal that the cache should be enabled or not. |
|
347
|
|
|
* |
|
348
|
|
|
* @var boolean |
|
349
|
|
|
* @Type("boolean") |
|
350
|
|
|
* @SerializedName("cache-enabled") |
|
351
|
|
|
*/ |
|
352
|
|
|
protected $cacheEnabled = true; |
|
353
|
|
|
|
|
354
|
|
|
/** |
|
355
|
|
|
* ArrayCollection with the information of the configured aliases. |
|
356
|
|
|
* |
|
357
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
|
358
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Alias>") |
|
359
|
|
|
*/ |
|
360
|
|
|
protected $aliases; |
|
361
|
|
|
|
|
362
|
|
|
/** |
|
363
|
|
|
* ArrayCollection with the information of the configured caches. |
|
364
|
|
|
* |
|
365
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
|
366
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Cache>") |
|
367
|
|
|
*/ |
|
368
|
|
|
protected $caches; |
|
369
|
|
|
|
|
370
|
|
|
/** |
|
371
|
|
|
* Return's the array with the plugins of the operation to use. |
|
372
|
|
|
* |
|
373
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the plugins |
|
374
|
|
|
* @throws \Exception Is thrown, if no plugins are available for the actual operation |
|
375
|
|
|
*/ |
|
376
|
|
|
public function getPlugins() |
|
377
|
|
|
{ |
|
378
|
|
|
|
|
379
|
|
|
// iterate over the operations and return the subjects of the actual one |
|
380
|
|
|
/** @var TechDivision\Import\Configuration\OperationInterface $operation */ |
|
381
|
|
|
foreach ($this->getOperations() as $operation) { |
|
382
|
|
|
if ($this->getOperation()->equals($operation)) { |
|
383
|
|
|
return $operation->getPlugins(); |
|
384
|
|
|
} |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
// throw an exception if no plugins are available |
|
388
|
|
|
throw new \Exception(sprintf('Can\'t find any plugins for operation %s', $this->getOperation())); |
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
|
|
/** |
|
392
|
|
|
* Map's the passed value to a boolean. |
|
393
|
|
|
* |
|
394
|
|
|
* @param string $value The value to map |
|
395
|
|
|
* |
|
396
|
|
|
* @return boolean The mapped value |
|
397
|
|
|
* @throws \Exception Is thrown, if the value can't be mapped |
|
398
|
|
|
*/ |
|
399
|
|
|
public function mapBoolean($value) |
|
400
|
|
|
{ |
|
401
|
|
|
|
|
402
|
|
|
// try to map the passed value to a boolean |
|
403
|
|
|
if (isset($this->booleanMapping[$value])) { |
|
404
|
|
|
return $this->booleanMapping[$value]; |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
// throw an exception if we can't convert the passed value |
|
408
|
|
|
throw new \Exception(sprintf('Can\'t convert %s to boolean', $value)); |
|
409
|
|
|
} |
|
410
|
|
|
|
|
411
|
|
|
/** |
|
412
|
|
|
* Return's the operation, initialize from the actual operation name. |
|
413
|
|
|
* |
|
414
|
|
|
* @return \TechDivision\Import\Configuration\OperationConfigurationInterface The operation instance |
|
415
|
|
|
*/ |
|
416
|
|
|
public function getOperation() |
|
417
|
|
|
{ |
|
418
|
|
|
return new Operation($this->getOperationName()); |
|
419
|
|
|
} |
|
420
|
|
|
|
|
421
|
|
|
/** |
|
422
|
|
|
* Return's the application's unique DI identifier. |
|
423
|
|
|
* |
|
424
|
|
|
* @return string The application's unique DI identifier |
|
425
|
|
|
*/ |
|
426
|
|
|
public function getId() |
|
427
|
|
|
{ |
|
428
|
|
|
return $this->id; |
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
/** |
|
432
|
|
|
* Return's the operation name that has to be used. |
|
433
|
|
|
* |
|
434
|
|
|
* @param string $operationName The operation name that has to be used |
|
435
|
|
|
* |
|
436
|
|
|
* @return void |
|
437
|
|
|
*/ |
|
438
|
|
|
public function setOperationName($operationName) |
|
439
|
|
|
{ |
|
440
|
|
|
return $this->operationName = $operationName; |
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
/** |
|
444
|
|
|
* Return's the operation name that has to be used. |
|
445
|
|
|
* |
|
446
|
|
|
* @return string The operation name that has to be used |
|
447
|
|
|
*/ |
|
448
|
|
|
public function getOperationName() |
|
449
|
|
|
{ |
|
450
|
|
|
return $this->operationName; |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
/** |
|
454
|
|
|
* Set's the Magento installation directory. |
|
455
|
|
|
* |
|
456
|
|
|
* @param string $installationDir The Magento installation directory |
|
457
|
|
|
* |
|
458
|
|
|
* @return void |
|
459
|
|
|
*/ |
|
460
|
|
|
public function setInstallationDir($installationDir) |
|
461
|
|
|
{ |
|
462
|
|
|
$this->installationDir = $installationDir; |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
/** |
|
466
|
|
|
* Return's the Magento installation directory. |
|
467
|
|
|
* |
|
468
|
|
|
* @return string The Magento installation directory |
|
469
|
|
|
*/ |
|
470
|
|
|
public function getInstallationDir() |
|
471
|
|
|
{ |
|
472
|
|
|
return $this->installationDir; |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
/** |
|
476
|
|
|
* Set's the source directory that has to be watched for new files. |
|
477
|
|
|
* |
|
478
|
|
|
* @param string $sourceDir The source directory |
|
479
|
|
|
* |
|
480
|
|
|
* @return void |
|
481
|
|
|
*/ |
|
482
|
|
|
public function setSourceDir($sourceDir) |
|
483
|
|
|
{ |
|
484
|
|
|
$this->sourceDir = $sourceDir; |
|
485
|
|
|
} |
|
486
|
|
|
|
|
487
|
|
|
/** |
|
488
|
|
|
* Return's the source directory that has to be watched for new files. |
|
489
|
|
|
* |
|
490
|
|
|
* @return string The source directory |
|
491
|
|
|
*/ |
|
492
|
|
|
public function getSourceDir() |
|
493
|
|
|
{ |
|
494
|
|
|
return $this->sourceDir; |
|
495
|
|
|
} |
|
496
|
|
|
|
|
497
|
|
|
/** |
|
498
|
|
|
* Set's the target directory with the files that has been imported. |
|
499
|
|
|
* |
|
500
|
|
|
* @param string $targetDir The target directory |
|
501
|
|
|
* |
|
502
|
|
|
* @return void |
|
503
|
|
|
*/ |
|
504
|
|
|
public function setTargetDir($targetDir) |
|
505
|
|
|
{ |
|
506
|
|
|
$this->targetDir = $targetDir; |
|
507
|
|
|
} |
|
508
|
|
|
|
|
509
|
|
|
/** |
|
510
|
|
|
* Return's the target directory with the files that has been imported. |
|
511
|
|
|
* |
|
512
|
|
|
* @return string The target directory |
|
513
|
|
|
*/ |
|
514
|
|
|
public function getTargetDir() |
|
515
|
|
|
{ |
|
516
|
|
|
return $this->targetDir; |
|
517
|
|
|
} |
|
518
|
|
|
|
|
519
|
|
|
/** |
|
520
|
|
|
* Set's the Magento edition, EE or CE. |
|
521
|
|
|
* |
|
522
|
|
|
* @param string $magentoEdition The Magento edition |
|
523
|
|
|
* |
|
524
|
|
|
* @return void |
|
525
|
|
|
*/ |
|
526
|
|
|
public function setMagentoEdition($magentoEdition) |
|
527
|
|
|
{ |
|
528
|
|
|
$this->magentoEdition = $magentoEdition; |
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
/** |
|
532
|
|
|
* Return's the Magento edition, EE or CE. |
|
533
|
|
|
* |
|
534
|
|
|
* @return string The Magento edition |
|
535
|
|
|
*/ |
|
536
|
|
|
public function getMagentoEdition() |
|
537
|
|
|
{ |
|
538
|
|
|
return $this->magentoEdition; |
|
539
|
|
|
} |
|
540
|
|
|
|
|
541
|
|
|
/** |
|
542
|
|
|
* Return's the Magento version, e. g. 2.1.0. |
|
543
|
|
|
* |
|
544
|
|
|
* @param string $magentoVersion The Magento version |
|
545
|
|
|
* |
|
546
|
|
|
* @return void |
|
547
|
|
|
*/ |
|
548
|
|
|
public function setMagentoVersion($magentoVersion) |
|
549
|
|
|
{ |
|
550
|
|
|
$this->magentoVersion = $magentoVersion; |
|
551
|
|
|
} |
|
552
|
|
|
|
|
553
|
|
|
/** |
|
554
|
|
|
* Return's the Magento version, e. g. 2.1.0. |
|
555
|
|
|
* |
|
556
|
|
|
* @return string The Magento version |
|
557
|
|
|
*/ |
|
558
|
|
|
public function getMagentoVersion() |
|
559
|
|
|
{ |
|
560
|
|
|
return $this->magentoVersion; |
|
561
|
|
|
} |
|
562
|
|
|
|
|
563
|
|
|
/** |
|
564
|
|
|
* Set's the subject's source date format to use. |
|
565
|
|
|
* |
|
566
|
|
|
* @param string $sourceDateFormat The source date format |
|
567
|
|
|
* |
|
568
|
|
|
* @return void |
|
569
|
|
|
*/ |
|
570
|
|
|
public function setSourceDateFormat($sourceDateFormat) |
|
571
|
|
|
{ |
|
572
|
|
|
$this->sourceDateFormat = $sourceDateFormat; |
|
|
|
|
|
|
573
|
|
|
} |
|
574
|
|
|
|
|
575
|
|
|
/** |
|
576
|
|
|
* Return's the entity type code to be used. |
|
577
|
|
|
* |
|
578
|
|
|
* @return string The entity type code to be used |
|
579
|
|
|
*/ |
|
580
|
|
|
public function getEntityTypeCode() |
|
581
|
|
|
{ |
|
582
|
|
|
return $this->entityTypeCode; |
|
583
|
|
|
} |
|
584
|
|
|
|
|
585
|
|
|
/** |
|
586
|
|
|
* Set's the entity type code to be used. |
|
587
|
|
|
* |
|
588
|
|
|
* @param string $entityTypeCode The entity type code |
|
589
|
|
|
* |
|
590
|
|
|
* @return void |
|
591
|
|
|
*/ |
|
592
|
|
|
public function setEntityTypeCode($entityTypeCode) |
|
593
|
|
|
{ |
|
594
|
|
|
$this->entityTypeCode = $entityTypeCode; |
|
595
|
|
|
} |
|
596
|
|
|
|
|
597
|
|
|
/** |
|
598
|
|
|
* Return's the multiple field delimiter character to use, default value is comma (,). |
|
599
|
|
|
* |
|
600
|
|
|
* @return string The multiple field delimiter character |
|
601
|
|
|
*/ |
|
602
|
|
|
public function getMultipleFieldDelimiter() |
|
603
|
|
|
{ |
|
604
|
|
|
return $this->multipleFieldDelimiter; |
|
605
|
|
|
} |
|
606
|
|
|
|
|
607
|
|
|
/** |
|
608
|
|
|
* Return's the multiple value delimiter character to use, default value is comma (|). |
|
609
|
|
|
* |
|
610
|
|
|
* @return string The multiple value delimiter character |
|
611
|
|
|
*/ |
|
612
|
|
|
public function getMultipleValueDelimiter() |
|
613
|
|
|
{ |
|
614
|
|
|
return $this->multipleValueDelimiter; |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
/** |
|
618
|
|
|
* Queries whether or not strict mode is enabled or not, default is TRUE. |
|
619
|
|
|
* |
|
620
|
|
|
* @return boolean TRUE if strict mode is enabled, else FALSE |
|
621
|
|
|
*/ |
|
622
|
|
|
public function isStrictMode() |
|
623
|
|
|
{ |
|
624
|
|
|
return $this->strictMode; |
|
625
|
|
|
} |
|
626
|
|
|
|
|
627
|
|
|
/** |
|
628
|
|
|
* Remove's all configured database configuration. |
|
629
|
|
|
* |
|
630
|
|
|
* @return void |
|
631
|
|
|
*/ |
|
632
|
|
|
public function clearDatabases() |
|
633
|
|
|
{ |
|
634
|
|
|
$this->databases->clear(); |
|
635
|
|
|
} |
|
636
|
|
|
|
|
637
|
|
|
/** |
|
638
|
|
|
* Add's the passed database configuration. |
|
639
|
|
|
* |
|
640
|
|
|
* @param \TechDivision\Import\Configuration\DatabaseConfigurationInterface $database The database configuration |
|
641
|
|
|
* |
|
642
|
|
|
* @return void |
|
643
|
|
|
*/ |
|
644
|
|
|
public function addDatabase(DatabaseConfigurationInterface $database) |
|
645
|
|
|
{ |
|
646
|
|
|
$this->databases->add($database); |
|
647
|
|
|
} |
|
648
|
|
|
|
|
649
|
|
|
/** |
|
650
|
|
|
* Return's the number database configurations. |
|
651
|
|
|
* |
|
652
|
|
|
* @return integer The number of database configurations |
|
653
|
|
|
*/ |
|
654
|
|
|
public function countDatabases() |
|
655
|
|
|
{ |
|
656
|
|
|
return $this->databases->count(); |
|
657
|
|
|
} |
|
658
|
|
|
|
|
659
|
|
|
/** |
|
660
|
|
|
* Return's the database configuration with the passed ID. |
|
661
|
|
|
* |
|
662
|
|
|
* @param string $id The ID of the database connection to return |
|
663
|
|
|
* |
|
664
|
|
|
* @return \TechDivision\Import\Configuration\DatabaseConfigurationInterface The database configuration |
|
665
|
|
|
* @throws \Exception Is thrown, if no database configuration is available |
|
666
|
|
|
*/ |
|
667
|
|
|
public function getDatabaseById($id) |
|
668
|
|
|
{ |
|
669
|
|
|
|
|
670
|
|
|
// iterate over the configured databases and return the one with the passed ID |
|
671
|
|
|
/** @var TechDivision\Import\Configuration\DatabaseInterface $database */ |
|
672
|
|
|
foreach ($this->databases as $database) { |
|
673
|
|
|
if ($database->getId() === $id && $this->isValidDatabaseType($database)) { |
|
674
|
|
|
return $database; |
|
675
|
|
|
} |
|
676
|
|
|
} |
|
677
|
|
|
|
|
678
|
|
|
// throw an exception, if the database with the passed ID is NOT configured |
|
679
|
|
|
throw new \Exception(sprintf('Database with ID %s can not be found or has an invalid type', $id)); |
|
680
|
|
|
} |
|
681
|
|
|
|
|
682
|
|
|
/** |
|
683
|
|
|
* Return's the databases for the given type. |
|
684
|
|
|
* |
|
685
|
|
|
* @param string $type The database type to return the configurations for |
|
686
|
|
|
* |
|
687
|
|
|
* @return \Doctrine\Common\Collections\Collection The collection with the database configurations |
|
688
|
|
|
*/ |
|
689
|
|
|
public function getDatabasesByType($type) |
|
690
|
|
|
{ |
|
691
|
|
|
|
|
692
|
|
|
// initialize the collection for the database configurations |
|
693
|
|
|
$databases = new ArrayCollection(); |
|
694
|
|
|
|
|
695
|
|
|
// iterate over the configured databases and return the one with the passed ID |
|
696
|
|
|
/** @var TechDivision\Import\Configuration\DatabaseInterface $database */ |
|
697
|
|
|
foreach ($this->databases as $database) { |
|
698
|
|
|
if ($database->getType() === $type && $this->isValidDatabaseType($database)) { |
|
699
|
|
|
$databases->add($database); |
|
700
|
|
|
} |
|
701
|
|
|
} |
|
702
|
|
|
|
|
703
|
|
|
// return the database configurations |
|
704
|
|
|
return $databases; |
|
705
|
|
|
} |
|
706
|
|
|
|
|
707
|
|
|
/** |
|
708
|
|
|
* Query's whether or not the passed database configuration has a valid type. |
|
709
|
|
|
* |
|
710
|
|
|
* @return boolean TRUE if the passed database configuration has a valid type, else FALSE |
|
711
|
|
|
*/ |
|
712
|
|
|
protected function isValidDatabaseType(DatabaseConfigurationInterface $database) |
|
713
|
|
|
{ |
|
714
|
|
|
return in_array(strtolower($database->getType()), $this->availableDatabaseTypes); |
|
715
|
|
|
} |
|
716
|
|
|
|
|
717
|
|
|
/** |
|
718
|
|
|
* Return's the database configuration. |
|
719
|
|
|
* |
|
720
|
|
|
* If an explicit DB ID is specified, the method tries to return the database with this ID. If |
|
721
|
|
|
* the database configuration is NOT available, an execption is thrown. |
|
722
|
|
|
* |
|
723
|
|
|
* If no explicit DB ID is specified, the method tries to return the default database configuration, |
|
724
|
|
|
* if not available the first one. |
|
725
|
|
|
* |
|
726
|
|
|
* @return \TechDivision\Import\Configuration\DatabaseConfigurationInterface The database configuration |
|
727
|
|
|
* @throws \Exception Is thrown, if no database configuration is available |
|
728
|
|
|
*/ |
|
729
|
|
|
public function getDatabase() |
|
730
|
|
|
{ |
|
731
|
|
|
|
|
732
|
|
|
// if a DB ID has been set, try to load the database |
|
733
|
|
|
if ($useDbId = $this->getUseDbId()) { |
|
734
|
|
|
return $this->getDatabaseById($useDbId); |
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
// iterate over the configured databases and try return the default database |
|
738
|
|
|
/** @var TechDivision\Import\Configuration\DatabaseInterface $database */ |
|
739
|
|
|
foreach ($this->databases as $database) { |
|
740
|
|
|
if ($database->isDefault() && $this->isValidDatabaseType($database)) { |
|
741
|
|
|
return $database; |
|
742
|
|
|
} |
|
743
|
|
|
} |
|
744
|
|
|
|
|
745
|
|
|
// try to return the first database configurtion |
|
746
|
|
|
if ($this->databases->count() > 0) { |
|
747
|
|
|
return $this->databases->first(); |
|
748
|
|
|
} |
|
749
|
|
|
|
|
750
|
|
|
// throw an exception, if no database configuration is available |
|
751
|
|
|
throw new \Exception('There is no database configuration available'); |
|
752
|
|
|
} |
|
753
|
|
|
|
|
754
|
|
|
/** |
|
755
|
|
|
* Return's the ArrayCollection with the configured operations. |
|
756
|
|
|
* |
|
757
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the operations |
|
758
|
|
|
*/ |
|
759
|
|
|
public function getOperations() |
|
760
|
|
|
{ |
|
761
|
|
|
return $this->operations; |
|
762
|
|
|
} |
|
763
|
|
|
|
|
764
|
|
|
/** |
|
765
|
|
|
* Return's the ArrayCollection with the configured loggers. |
|
766
|
|
|
* |
|
767
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the loggers |
|
768
|
|
|
*/ |
|
769
|
|
|
public function getLoggers() |
|
770
|
|
|
{ |
|
771
|
|
|
return $this->loggers; |
|
772
|
|
|
} |
|
773
|
|
|
|
|
774
|
|
|
/** |
|
775
|
|
|
* Set's the flag that import artefacts have to be archived or not. |
|
776
|
|
|
* |
|
777
|
|
|
* @param boolean $archiveArtefacts TRUE if artefacts have to be archived, else FALSE |
|
778
|
|
|
* |
|
779
|
|
|
* @return void |
|
780
|
|
|
*/ |
|
781
|
|
|
public function setArchiveArtefacts($archiveArtefacts) |
|
782
|
|
|
{ |
|
783
|
|
|
$this->archiveArtefacts = $archiveArtefacts; |
|
784
|
|
|
} |
|
785
|
|
|
|
|
786
|
|
|
/** |
|
787
|
|
|
* Return's the TRUE if the import artefacts have to be archived. |
|
788
|
|
|
* |
|
789
|
|
|
* @return boolean TRUE if the import artefacts have to be archived |
|
790
|
|
|
*/ |
|
791
|
|
|
public function haveArchiveArtefacts() |
|
792
|
|
|
{ |
|
793
|
|
|
return $this->archiveArtefacts; |
|
794
|
|
|
} |
|
795
|
|
|
|
|
796
|
|
|
/** |
|
797
|
|
|
* The directory where the archives will be stored. |
|
798
|
|
|
* |
|
799
|
|
|
* @param string $archiveDir The archive directory |
|
800
|
|
|
* |
|
801
|
|
|
* @return void |
|
802
|
|
|
*/ |
|
803
|
|
|
public function setArchiveDir($archiveDir) |
|
804
|
|
|
{ |
|
805
|
|
|
$this->archiveDir = $archiveDir; |
|
806
|
|
|
} |
|
807
|
|
|
|
|
808
|
|
|
/** |
|
809
|
|
|
* The directory where the archives will be stored. |
|
810
|
|
|
* |
|
811
|
|
|
* @return string The archive directory |
|
812
|
|
|
*/ |
|
813
|
|
|
public function getArchiveDir() |
|
814
|
|
|
{ |
|
815
|
|
|
return $this->archiveDir; |
|
816
|
|
|
} |
|
817
|
|
|
|
|
818
|
|
|
/** |
|
819
|
|
|
* Set's the debug mode. |
|
820
|
|
|
* |
|
821
|
|
|
* @param boolean $debugMode TRUE if debug mode is enabled, else FALSE |
|
822
|
|
|
* |
|
823
|
|
|
* @return void |
|
824
|
|
|
*/ |
|
825
|
|
|
public function setDebugMode($debugMode) |
|
826
|
|
|
{ |
|
827
|
|
|
$this->debugMode = $debugMode; |
|
828
|
|
|
} |
|
829
|
|
|
|
|
830
|
|
|
/** |
|
831
|
|
|
* Queries whether or not debug mode is enabled or not, default is TRUE. |
|
832
|
|
|
* |
|
833
|
|
|
* @return boolean TRUE if debug mode is enabled, else FALSE |
|
834
|
|
|
*/ |
|
835
|
|
|
public function isDebugMode() |
|
836
|
|
|
{ |
|
837
|
|
|
return $this->debugMode; |
|
838
|
|
|
} |
|
839
|
|
|
|
|
840
|
|
|
/** |
|
841
|
|
|
* Set's the log level to use. |
|
842
|
|
|
* |
|
843
|
|
|
* @param string $logLevel The log level to use |
|
844
|
|
|
* |
|
845
|
|
|
* @return void |
|
846
|
|
|
*/ |
|
847
|
|
|
public function setLogLevel($logLevel) |
|
848
|
|
|
{ |
|
849
|
|
|
$this->logLevel = $logLevel; |
|
850
|
|
|
} |
|
851
|
|
|
|
|
852
|
|
|
/** |
|
853
|
|
|
* Return's the log level to use. |
|
854
|
|
|
* |
|
855
|
|
|
* @return string The log level to use |
|
856
|
|
|
*/ |
|
857
|
|
|
public function getLogLevel() |
|
858
|
|
|
{ |
|
859
|
|
|
return $this->logLevel; |
|
860
|
|
|
} |
|
861
|
|
|
|
|
862
|
|
|
/** |
|
863
|
|
|
* Set's the explicit DB ID to use. |
|
864
|
|
|
* |
|
865
|
|
|
* @param string $useDbId The explicit DB ID to use |
|
866
|
|
|
* |
|
867
|
|
|
* @return void |
|
868
|
|
|
*/ |
|
869
|
|
|
public function setUseDbId($useDbId) |
|
870
|
|
|
{ |
|
871
|
|
|
$this->useDbId = $useDbId; |
|
872
|
|
|
} |
|
873
|
|
|
|
|
874
|
|
|
/** |
|
875
|
|
|
* Return's the explicit DB ID to use. |
|
876
|
|
|
* |
|
877
|
|
|
* @return string The explicit DB ID to use |
|
878
|
|
|
*/ |
|
879
|
|
|
public function getUseDbId() |
|
880
|
|
|
{ |
|
881
|
|
|
return $this->useDbId; |
|
882
|
|
|
} |
|
883
|
|
|
|
|
884
|
|
|
/** |
|
885
|
|
|
* Set's the PID filename to use. |
|
886
|
|
|
* |
|
887
|
|
|
* @param string $pidFilename The PID filename to use |
|
888
|
|
|
* |
|
889
|
|
|
* @return void |
|
890
|
|
|
*/ |
|
891
|
|
|
public function setPidFilename($pidFilename) |
|
892
|
|
|
{ |
|
893
|
|
|
$this->pidFilename = $pidFilename; |
|
894
|
|
|
} |
|
895
|
|
|
|
|
896
|
|
|
/** |
|
897
|
|
|
* Return's the PID filename to use. |
|
898
|
|
|
* |
|
899
|
|
|
* @return string The PID filename to use |
|
900
|
|
|
*/ |
|
901
|
|
|
public function getPidFilename() |
|
902
|
|
|
{ |
|
903
|
|
|
return $this->pidFilename; |
|
904
|
|
|
} |
|
905
|
|
|
|
|
906
|
|
|
/** |
|
907
|
|
|
* Set's the systemm name to be used. |
|
908
|
|
|
* |
|
909
|
|
|
* @param string $systemName The system name to be used |
|
910
|
|
|
* |
|
911
|
|
|
* @return void |
|
912
|
|
|
*/ |
|
913
|
|
|
public function setSystemName($systemName) |
|
914
|
|
|
{ |
|
915
|
|
|
$this->systemName = $systemName; |
|
916
|
|
|
} |
|
917
|
|
|
|
|
918
|
|
|
/** |
|
919
|
|
|
* Return's the systemm name to be used. |
|
920
|
|
|
* |
|
921
|
|
|
* @return string The system name to be used |
|
922
|
|
|
*/ |
|
923
|
|
|
public function getSystemName() |
|
924
|
|
|
{ |
|
925
|
|
|
return $this->systemName; |
|
926
|
|
|
} |
|
927
|
|
|
|
|
928
|
|
|
/** |
|
929
|
|
|
* Set's the collection with the path of the Magento Edition specific extension libraries. |
|
930
|
|
|
* |
|
931
|
|
|
* @param array $extensionLibraries The paths of the Magento Edition specific extension libraries |
|
932
|
|
|
* |
|
933
|
|
|
* @return void |
|
934
|
|
|
*/ |
|
935
|
|
|
public function setExtensionLibraries(array $extensionLibraries) |
|
936
|
|
|
{ |
|
937
|
|
|
$this->extensionLibraries = $extensionLibraries; |
|
938
|
|
|
} |
|
939
|
|
|
|
|
940
|
|
|
/** |
|
941
|
|
|
* Return's an array with the path of the Magento Edition specific extension libraries. |
|
942
|
|
|
* |
|
943
|
|
|
* @return array The paths of the Magento Edition specific extension libraries |
|
944
|
|
|
*/ |
|
945
|
|
|
public function getExtensionLibraries() |
|
946
|
|
|
{ |
|
947
|
|
|
return $this->extensionLibraries; |
|
948
|
|
|
} |
|
949
|
|
|
|
|
950
|
|
|
/** |
|
951
|
|
|
* Return's a collection with the path to additional vendor directories. |
|
952
|
|
|
* |
|
953
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The paths to additional vendor directories |
|
954
|
|
|
*/ |
|
955
|
|
|
public function getAdditionalVendorDirs() |
|
956
|
|
|
{ |
|
957
|
|
|
return $this->additionalVendorDirs; |
|
958
|
|
|
} |
|
959
|
|
|
|
|
960
|
|
|
/** |
|
961
|
|
|
* Lifecycle callback that will be invoked after deserialization. |
|
962
|
|
|
* |
|
963
|
|
|
* @return void |
|
964
|
|
|
* @PostDeserialize |
|
965
|
|
|
*/ |
|
966
|
|
|
public function postDeserialize() |
|
967
|
|
|
{ |
|
968
|
|
|
|
|
969
|
|
|
// create an empty collection if no loggers has been specified |
|
970
|
|
|
if ($this->loggers === null) { |
|
971
|
|
|
$this->loggers = new ArrayCollection(); |
|
972
|
|
|
} |
|
973
|
|
|
|
|
974
|
|
|
// create an empty collection if no operations has been specified |
|
975
|
|
|
if ($this->operations === null) { |
|
976
|
|
|
$this->operations = new ArrayCollection(); |
|
977
|
|
|
} |
|
978
|
|
|
|
|
979
|
|
|
// create an empty collection if no additional venor directories has been specified |
|
980
|
|
|
if ($this->additionalVendorDirs === null) { |
|
981
|
|
|
$this->additionalVendorDirs = new ArrayCollection(); |
|
982
|
|
|
} |
|
983
|
|
|
|
|
984
|
|
|
// create an empty collection if no caches has been specified |
|
985
|
|
|
if ($this->caches === null) { |
|
986
|
|
|
$this->caches = new ArrayCollection(); |
|
987
|
|
|
} |
|
988
|
|
|
|
|
989
|
|
|
// create an empty collection if no aliases has been specified |
|
990
|
|
|
if ($this->aliases === null) { |
|
991
|
|
|
$this->aliases = new ArrayCollection(); |
|
992
|
|
|
} |
|
993
|
|
|
} |
|
994
|
|
|
|
|
995
|
|
|
/** |
|
996
|
|
|
* The array with the subject's custom header mappings. |
|
997
|
|
|
* |
|
998
|
|
|
* @return array The custom header mappings |
|
999
|
|
|
*/ |
|
1000
|
|
|
public function getHeaderMappings() |
|
1001
|
|
|
{ |
|
1002
|
|
|
|
|
1003
|
|
|
// initialize the array for the custom header mappings |
|
1004
|
|
|
$headerMappings = array(); |
|
1005
|
|
|
|
|
1006
|
|
|
// try to load the configured header mappings |
|
1007
|
|
|
if ($headerMappingsAvailable = reset($this->headerMappings)) { |
|
1008
|
|
|
$headerMappings = $headerMappingsAvailable; |
|
1009
|
|
|
} |
|
1010
|
|
|
|
|
1011
|
|
|
// return the custom header mappings |
|
1012
|
|
|
return $headerMappings; |
|
1013
|
|
|
} |
|
1014
|
|
|
|
|
1015
|
|
|
/** |
|
1016
|
|
|
* The array with the subject's custom image types. |
|
1017
|
|
|
* |
|
1018
|
|
|
* @return array The custom image types |
|
1019
|
|
|
*/ |
|
1020
|
|
|
public function getImageTypes() |
|
1021
|
|
|
{ |
|
1022
|
|
|
|
|
1023
|
|
|
// initialize the array for the custom image types |
|
1024
|
|
|
$imageTypes = array(); |
|
1025
|
|
|
|
|
1026
|
|
|
// try to load the configured image types |
|
1027
|
|
|
if ($imageTypesAvailable = reset($this->imageTypes)) { |
|
1028
|
|
|
$imageTypes = $imageTypesAvailable; |
|
1029
|
|
|
} |
|
1030
|
|
|
|
|
1031
|
|
|
// return the custom image types |
|
1032
|
|
|
return $imageTypes; |
|
1033
|
|
|
} |
|
1034
|
|
|
|
|
1035
|
|
|
/** |
|
1036
|
|
|
* Set's the flag that decides whether or not the import should be wrapped within a single transaction. |
|
1037
|
|
|
* |
|
1038
|
|
|
* @param boolean $singleTransaction TRUE if the import should be wrapped in a single transation, else FALSE |
|
1039
|
|
|
* |
|
1040
|
|
|
* @return void |
|
1041
|
|
|
*/ |
|
1042
|
|
|
public function setSingleTransaction($singleTransaction) |
|
1043
|
|
|
{ |
|
1044
|
|
|
$this->singleTransaction = $singleTransaction; |
|
1045
|
|
|
} |
|
1046
|
|
|
|
|
1047
|
|
|
/** |
|
1048
|
|
|
* Whether or not the import should be wrapped within a single transation. |
|
1049
|
|
|
* |
|
1050
|
|
|
* @return boolean TRUE if the import should be wrapped in a single transation, else FALSE |
|
1051
|
|
|
*/ |
|
1052
|
|
|
public function isSingleTransaction() |
|
1053
|
|
|
{ |
|
1054
|
|
|
return $this->singleTransaction; |
|
1055
|
|
|
} |
|
1056
|
|
|
|
|
1057
|
|
|
/** |
|
1058
|
|
|
* Set's the flag that decides whether or not the the cache has been enabled. |
|
1059
|
|
|
* |
|
1060
|
|
|
* @param boolean $cacheEnabled TRUE if the cache has been enabled, else FALSE |
|
1061
|
|
|
* |
|
1062
|
|
|
* @return void |
|
1063
|
|
|
*/ |
|
1064
|
|
|
public function setCacheEnabled($cacheEnabled) |
|
1065
|
|
|
{ |
|
1066
|
|
|
$this->cacheEnabled = $cacheEnabled; |
|
1067
|
|
|
} |
|
1068
|
|
|
|
|
1069
|
|
|
/** |
|
1070
|
|
|
* Whether or not the cache functionality should be enabled. |
|
1071
|
|
|
* |
|
1072
|
|
|
* @return boolean TRUE if the cache has to be enabled, else FALSE |
|
1073
|
|
|
*/ |
|
1074
|
|
|
public function isCacheEnabled() |
|
1075
|
|
|
{ |
|
1076
|
|
|
return $this->cacheEnabled; |
|
1077
|
|
|
} |
|
1078
|
|
|
|
|
1079
|
|
|
/** |
|
1080
|
|
|
* Set's the passed serial from the commandline to the configuration. |
|
1081
|
|
|
* |
|
1082
|
|
|
* @param string $serial The serial from the commandline |
|
1083
|
|
|
*/ |
|
1084
|
|
|
public function setSerial($serial) |
|
1085
|
|
|
{ |
|
1086
|
|
|
$this->serial = $serial; |
|
1087
|
|
|
} |
|
1088
|
|
|
|
|
1089
|
|
|
/** |
|
1090
|
|
|
* Return's the serial from the commandline. |
|
1091
|
|
|
* |
|
1092
|
|
|
* @return string The serial |
|
1093
|
|
|
*/ |
|
1094
|
|
|
public function getSerial() |
|
1095
|
|
|
{ |
|
1096
|
|
|
return $this->serial; |
|
1097
|
|
|
} |
|
1098
|
|
|
|
|
1099
|
|
|
/** |
|
1100
|
|
|
* Return's the configuration for the caches. |
|
1101
|
|
|
* |
|
1102
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The cache configurations |
|
1103
|
|
|
*/ |
|
1104
|
|
|
public function getCaches() |
|
1105
|
|
|
{ |
|
1106
|
|
|
|
|
1107
|
|
|
// iterate over the caches and set the parent configuration instance |
|
1108
|
|
|
foreach ($this->caches as $cache) { |
|
1109
|
|
|
$cache->setConfiguration($this); |
|
1110
|
|
|
} |
|
1111
|
|
|
|
|
1112
|
|
|
// return the array with the caches |
|
1113
|
|
|
return $this->caches; |
|
1114
|
|
|
} |
|
1115
|
|
|
|
|
1116
|
|
|
/** |
|
1117
|
|
|
* Return's the cache configuration for the passed type. |
|
1118
|
|
|
* |
|
1119
|
|
|
* @param string $type The cache type to return the configuation for |
|
1120
|
|
|
* |
|
1121
|
|
|
* @return \TechDivision\Import\Configuration\CacheConfigurationInterface The cache configuration |
|
1122
|
|
|
*/ |
|
1123
|
|
|
public function getCacheByType($type) |
|
1124
|
|
|
{ |
|
1125
|
|
|
|
|
1126
|
|
|
// load the available cache configurations |
|
1127
|
|
|
$caches = $this->getCaches(); |
|
1128
|
|
|
|
|
1129
|
|
|
// try to load the cache for the passed type |
|
1130
|
|
|
/** @var \TechDivision\Import\Configuration\CacheConfigurationInterface $cache */ |
|
1131
|
|
|
foreach ($caches as $cache) { |
|
1132
|
|
|
if ($cache->getType() === $type) { |
|
1133
|
|
|
return $cache; |
|
1134
|
|
|
} |
|
1135
|
|
|
} |
|
1136
|
|
|
} |
|
1137
|
|
|
|
|
1138
|
|
|
/** |
|
1139
|
|
|
* Return's the alias configuration. |
|
1140
|
|
|
* |
|
1141
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The alias configuration |
|
1142
|
|
|
*/ |
|
1143
|
|
|
public function getAliases() |
|
1144
|
|
|
{ |
|
1145
|
|
|
return $this->aliases; |
|
1146
|
|
|
} |
|
1147
|
|
|
} |
|
1148
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: