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