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