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
|
|
|
* Return's the array with the plugins of the operation to use. |
321
|
|
|
* |
322
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the plugins |
323
|
|
|
* @throws \Exception Is thrown, if no plugins are available for the actual operation |
324
|
|
|
*/ |
325
|
|
|
public function getPlugins() |
326
|
|
|
{ |
327
|
|
|
|
328
|
|
|
// iterate over the operations and return the subjects of the actual one |
329
|
|
|
/** @var TechDivision\Import\Configuration\OperationInterface $operation */ |
330
|
|
|
foreach ($this->getOperations() as $operation) { |
331
|
|
|
if ($this->getOperation()->equals($operation)) { |
332
|
|
|
return $operation->getPlugins(); |
333
|
|
|
} |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
// throw an exception if no plugins are available |
337
|
|
|
throw new \Exception(sprintf('Can\'t find any plugins for operation %s', $this->getOperation())); |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* Map's the passed value to a boolean. |
342
|
|
|
* |
343
|
|
|
* @param string $value The value to map |
344
|
|
|
* |
345
|
|
|
* @return boolean The mapped value |
346
|
|
|
* @throws \Exception Is thrown, if the value can't be mapped |
347
|
|
|
*/ |
348
|
|
|
public function mapBoolean($value) |
349
|
|
|
{ |
350
|
|
|
|
351
|
|
|
// try to map the passed value to a boolean |
352
|
|
|
if (isset($this->booleanMapping[$value])) { |
353
|
|
|
return $this->booleanMapping[$value]; |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
// throw an exception if we can't convert the passed value |
357
|
|
|
throw new \Exception(sprintf('Can\'t convert %s to boolean', $value)); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* Return's the operation, initialize from the actual operation name. |
362
|
|
|
* |
363
|
|
|
* @return \TechDivision\Import\Configuration\OperationInterface The operation instance |
364
|
|
|
*/ |
365
|
|
|
protected function getOperation() |
366
|
|
|
{ |
367
|
|
|
return new Operation($this->getOperationName()); |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
/** |
371
|
|
|
* Return's the operation name that has to be used. |
372
|
|
|
* |
373
|
|
|
* @param string $operationName The operation name that has to be used |
374
|
|
|
* |
375
|
|
|
* @return void |
376
|
|
|
*/ |
377
|
|
|
public function setOperationName($operationName) |
378
|
|
|
{ |
379
|
|
|
return $this->operationName = $operationName; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* Return's the operation name that has to be used. |
384
|
|
|
* |
385
|
|
|
* @return string The operation name that has to be used |
386
|
|
|
*/ |
387
|
|
|
public function getOperationName() |
388
|
|
|
{ |
389
|
|
|
return $this->operationName; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* Set's the Magento installation directory. |
394
|
|
|
* |
395
|
|
|
* @param string $installationDir The Magento installation directory |
396
|
|
|
* |
397
|
|
|
* @return void |
398
|
|
|
*/ |
399
|
|
|
public function setInstallationDir($installationDir) |
400
|
|
|
{ |
401
|
|
|
$this->installationDir = $installationDir; |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* Return's the Magento installation directory. |
406
|
|
|
* |
407
|
|
|
* @return string The Magento installation directory |
408
|
|
|
*/ |
409
|
|
|
public function getInstallationDir() |
410
|
|
|
{ |
411
|
|
|
return $this->installationDir; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* Set's the source directory that has to be watched for new files. |
416
|
|
|
* |
417
|
|
|
* @param string $sourceDir The source directory |
418
|
|
|
* |
419
|
|
|
* @return void |
420
|
|
|
*/ |
421
|
|
|
public function setSourceDir($sourceDir) |
422
|
|
|
{ |
423
|
|
|
$this->sourceDir = $sourceDir; |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
/** |
427
|
|
|
* Return's the source directory that has to be watched for new files. |
428
|
|
|
* |
429
|
|
|
* @return string The source directory |
430
|
|
|
*/ |
431
|
|
|
public function getSourceDir() |
432
|
|
|
{ |
433
|
|
|
return $this->sourceDir; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* Set's the target directory with the files that has been imported. |
438
|
|
|
* |
439
|
|
|
* @param string $targetDir The target directory |
440
|
|
|
* |
441
|
|
|
* @return void |
442
|
|
|
*/ |
443
|
|
|
public function setTargetDir($targetDir) |
444
|
|
|
{ |
445
|
|
|
$this->targetDir = $targetDir; |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
/** |
449
|
|
|
* Return's the target directory with the files that has been imported. |
450
|
|
|
* |
451
|
|
|
* @return string The target directory |
452
|
|
|
*/ |
453
|
|
|
public function getTargetDir() |
454
|
|
|
{ |
455
|
|
|
return $this->targetDir; |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
/** |
459
|
|
|
* Set's the Magento edition, EE or CE. |
460
|
|
|
* |
461
|
|
|
* @param string $magentoEdition The Magento edition |
462
|
|
|
* |
463
|
|
|
* @return void |
464
|
|
|
*/ |
465
|
|
|
public function setMagentoEdition($magentoEdition) |
466
|
|
|
{ |
467
|
|
|
$this->magentoEdition = $magentoEdition; |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
/** |
471
|
|
|
* Return's the Magento edition, EE or CE. |
472
|
|
|
* |
473
|
|
|
* @return string The Magento edition |
474
|
|
|
*/ |
475
|
|
|
public function getMagentoEdition() |
476
|
|
|
{ |
477
|
|
|
return $this->magentoEdition; |
478
|
|
|
} |
479
|
|
|
|
480
|
|
|
/** |
481
|
|
|
* Return's the Magento version, e. g. 2.1.0. |
482
|
|
|
* |
483
|
|
|
* @param string $magentoVersion The Magento version |
484
|
|
|
* |
485
|
|
|
* @return void |
486
|
|
|
*/ |
487
|
|
|
public function setMagentoVersion($magentoVersion) |
488
|
|
|
{ |
489
|
|
|
$this->magentoVersion = $magentoVersion; |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
/** |
493
|
|
|
* Return's the Magento version, e. g. 2.1.0. |
494
|
|
|
* |
495
|
|
|
* @return string The Magento version |
496
|
|
|
*/ |
497
|
|
|
public function getMagentoVersion() |
498
|
|
|
{ |
499
|
|
|
return $this->magentoVersion; |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
/** |
503
|
|
|
* Return's the subject's source date format to use. |
504
|
|
|
* |
505
|
|
|
* @return string The source date format |
506
|
|
|
*/ |
507
|
|
|
public function getSourceDateFormat() |
508
|
|
|
{ |
509
|
|
|
return $this->sourceDateFormat; |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* Set's the subject's source date format to use. |
514
|
|
|
* |
515
|
|
|
* @param string $sourceDateFormat The source date format |
516
|
|
|
* |
517
|
|
|
* @return void |
518
|
|
|
*/ |
519
|
|
|
public function setSourceDateFormat($sourceDateFormat) |
520
|
|
|
{ |
521
|
|
|
$this->sourceDateFormat = $sourceDateFormat; |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
/** |
525
|
|
|
* Return's the entity type code to be used. |
526
|
|
|
* |
527
|
|
|
* @return string The entity type code to be used |
528
|
|
|
*/ |
529
|
|
|
public function getEntityTypeCode() |
530
|
|
|
{ |
531
|
|
|
return $this->entityTypeCode; |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* Set's the entity type code to be used. |
536
|
|
|
* |
537
|
|
|
* @param string $entityTypeCode The entity type code |
538
|
|
|
* |
539
|
|
|
* @return void |
540
|
|
|
*/ |
541
|
|
|
public function setEntityTypeCode($entityTypeCode) |
542
|
|
|
{ |
543
|
|
|
$this->entityTypeCode = $entityTypeCode; |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
/** |
547
|
|
|
* Return's the multiple field delimiter character to use, default value is comma (,). |
548
|
|
|
* |
549
|
|
|
* @return string The multiple field delimiter character |
550
|
|
|
*/ |
551
|
|
|
public function getMultipleFieldDelimiter() |
552
|
|
|
{ |
553
|
|
|
return $this->multipleFieldDelimiter; |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
/** |
557
|
|
|
* Return's the multiple value delimiter character to use, default value is comma (|). |
558
|
|
|
* |
559
|
|
|
* @return string The multiple value delimiter character |
560
|
|
|
*/ |
561
|
|
|
public function getMultipleValueDelimiter() |
562
|
|
|
{ |
563
|
|
|
return $this->multipleValueDelimiter; |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* Return's the delimiter character to use, default value is comma (,). |
568
|
|
|
* |
569
|
|
|
* @return string The delimiter character |
570
|
|
|
*/ |
571
|
|
|
public function getDelimiter() |
572
|
|
|
{ |
573
|
|
|
return $this->delimiter; |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* The enclosure character to use, default value is double quotation ("). |
578
|
|
|
* |
579
|
|
|
* @return string The enclosure character |
580
|
|
|
*/ |
581
|
|
|
public function getEnclosure() |
582
|
|
|
{ |
583
|
|
|
return $this->enclosure; |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
/** |
587
|
|
|
* The escape character to use, default value is backslash (\). |
588
|
|
|
* |
589
|
|
|
* @return string The escape character |
590
|
|
|
*/ |
591
|
|
|
public function getEscape() |
592
|
|
|
{ |
593
|
|
|
return $this->escape; |
594
|
|
|
} |
595
|
|
|
|
596
|
|
|
/** |
597
|
|
|
* The file encoding of the CSV source file, default value is UTF-8. |
598
|
|
|
* |
599
|
|
|
* @return string The charset used by the CSV source file |
600
|
|
|
*/ |
601
|
|
|
public function getFromCharset() |
602
|
|
|
{ |
603
|
|
|
return $this->fromCharset; |
604
|
|
|
} |
605
|
|
|
|
606
|
|
|
/** |
607
|
|
|
* The file encoding of the CSV targetfile, default value is UTF-8. |
608
|
|
|
* |
609
|
|
|
* @return string The charset used by the CSV target file |
610
|
|
|
*/ |
611
|
|
|
public function getToCharset() |
612
|
|
|
{ |
613
|
|
|
return $this->toCharset; |
614
|
|
|
} |
615
|
|
|
|
616
|
|
|
/** |
617
|
|
|
* The file mode of the CSV target file, either one of write or append, default is write. |
618
|
|
|
* |
619
|
|
|
* @return string The file mode of the CSV target file |
620
|
|
|
*/ |
621
|
|
|
public function getFileMode() |
622
|
|
|
{ |
623
|
|
|
return $this->fileMode; |
624
|
|
|
} |
625
|
|
|
|
626
|
|
|
/** |
627
|
|
|
* Queries whether or not strict mode is enabled or not, default is TRUE. |
628
|
|
|
* |
629
|
|
|
* @return boolean TRUE if strict mode is enabled, else FALSE |
630
|
|
|
*/ |
631
|
|
|
public function isStrictMode() |
632
|
|
|
{ |
633
|
|
|
return $this->strictMode; |
634
|
|
|
} |
635
|
|
|
|
636
|
|
|
/** |
637
|
|
|
* Remove's all configured database configuration. |
638
|
|
|
* |
639
|
|
|
* @return void |
640
|
|
|
*/ |
641
|
|
|
public function clearDatabases() |
642
|
|
|
{ |
643
|
|
|
$this->databases->clear(); |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
/** |
647
|
|
|
* Add's the passed database configuration. |
648
|
|
|
* |
649
|
|
|
* @param \TechDivision\Import\Configuration\DatabaseConfigurationInterface $database The database configuration |
650
|
|
|
* |
651
|
|
|
* @return void |
652
|
|
|
*/ |
653
|
|
|
public function addDatabase(DatabaseConfigurationInterface $database) |
654
|
|
|
{ |
655
|
|
|
$this->databases->add($database); |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
/** |
659
|
|
|
* Return's the number database configurations. |
660
|
|
|
* |
661
|
|
|
* @return integer The number of database configurations |
662
|
|
|
*/ |
663
|
|
|
public function countDatabases() |
664
|
|
|
{ |
665
|
|
|
return $this->databases->count(); |
666
|
|
|
} |
667
|
|
|
|
668
|
|
|
/** |
669
|
|
|
* Return's the database configuration. |
670
|
|
|
* |
671
|
|
|
* If an explicit DB ID is specified, the method tries to return the database with this ID. If |
672
|
|
|
* the database configuration is NOT available, an execption is thrown. |
673
|
|
|
* |
674
|
|
|
* If no explicit DB ID is specified, the method tries to return the default database configuration, |
675
|
|
|
* if not available the first one. |
676
|
|
|
* |
677
|
|
|
* @return \TechDivision\Import\Configuration\Jms\Configuration\Database The database configuration |
678
|
|
|
* @throws \Exception Is thrown, if no database configuration is available |
679
|
|
|
*/ |
680
|
|
|
public function getDatabase() |
681
|
|
|
{ |
682
|
|
|
|
683
|
|
|
// if a DB ID has been set, try to load the database |
684
|
|
|
if ($useDbId = $this->getUseDbId()) { |
685
|
|
|
// iterate over the configured databases and return the one with the passed ID |
686
|
|
|
/** @var TechDivision\Import\Configuration\DatabaseInterface $database */ |
687
|
|
|
foreach ($this->databases as $database) { |
688
|
|
|
if ($database->getId() === $useDbId) { |
689
|
|
|
return $database; |
690
|
|
|
} |
691
|
|
|
} |
692
|
|
|
|
693
|
|
|
// throw an exception, if the database with the passed ID is NOT configured |
694
|
|
|
throw new \Exception(sprintf('Database with ID %s can not be found', $useDbId)); |
695
|
|
|
} |
696
|
|
|
|
697
|
|
|
// iterate over the configured databases and try return the default database |
698
|
|
|
/** @var TechDivision\Import\Configuration\DatabaseInterface $database */ |
699
|
|
|
foreach ($this->databases as $database) { |
700
|
|
|
if ($database->isDefault()) { |
701
|
|
|
return $database; |
702
|
|
|
} |
703
|
|
|
} |
704
|
|
|
|
705
|
|
|
// try to return the first database configurtion |
706
|
|
|
if ($this->databases->count() > 0) { |
707
|
|
|
return $this->databases->first(); |
708
|
|
|
} |
709
|
|
|
|
710
|
|
|
// throw an exception, if no database configuration is available |
711
|
|
|
throw new \Exception('There is no database configuration available'); |
712
|
|
|
} |
713
|
|
|
|
714
|
|
|
/** |
715
|
|
|
* Return's the ArrayCollection with the configured operations. |
716
|
|
|
* |
717
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the operations |
718
|
|
|
*/ |
719
|
|
|
public function getOperations() |
720
|
|
|
{ |
721
|
|
|
return $this->operations; |
722
|
|
|
} |
723
|
|
|
|
724
|
|
|
/** |
725
|
|
|
* Return's the ArrayCollection with the configured loggers. |
726
|
|
|
* |
727
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the loggers |
728
|
|
|
*/ |
729
|
|
|
public function getLoggers() |
730
|
|
|
{ |
731
|
|
|
return $this->loggers; |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
/** |
735
|
|
|
* Set's the flag that import artefacts have to be archived or not. |
736
|
|
|
* |
737
|
|
|
* @param boolean $archiveArtefacts TRUE if artefacts have to be archived, else FALSE |
738
|
|
|
* |
739
|
|
|
* @return void |
740
|
|
|
*/ |
741
|
|
|
public function setArchiveArtefacts($archiveArtefacts) |
742
|
|
|
{ |
743
|
|
|
$this->archiveArtefacts = $archiveArtefacts; |
744
|
|
|
} |
745
|
|
|
|
746
|
|
|
/** |
747
|
|
|
* Return's the TRUE if the import artefacts have to be archived. |
748
|
|
|
* |
749
|
|
|
* @return boolean TRUE if the import artefacts have to be archived |
750
|
|
|
*/ |
751
|
|
|
public function haveArchiveArtefacts() |
752
|
|
|
{ |
753
|
|
|
return $this->archiveArtefacts; |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
/** |
757
|
|
|
* The directory where the archives will be stored. |
758
|
|
|
* |
759
|
|
|
* @param string $archiveDir The archive directory |
760
|
|
|
* |
761
|
|
|
* @return void |
762
|
|
|
*/ |
763
|
|
|
public function setArchiveDir($archiveDir) |
764
|
|
|
{ |
765
|
|
|
$this->archiveDir = $archiveDir; |
766
|
|
|
} |
767
|
|
|
|
768
|
|
|
/** |
769
|
|
|
* The directory where the archives will be stored. |
770
|
|
|
* |
771
|
|
|
* @return string The archive directory |
772
|
|
|
*/ |
773
|
|
|
public function getArchiveDir() |
774
|
|
|
{ |
775
|
|
|
return $this->archiveDir; |
776
|
|
|
} |
777
|
|
|
|
778
|
|
|
/** |
779
|
|
|
* Set's the debug mode. |
780
|
|
|
* |
781
|
|
|
* @param boolean $debugMode TRUE if debug mode is enabled, else FALSE |
782
|
|
|
* |
783
|
|
|
* @return void |
784
|
|
|
*/ |
785
|
|
|
public function setDebugMode($debugMode) |
786
|
|
|
{ |
787
|
|
|
$this->debugMode = $debugMode; |
788
|
|
|
} |
789
|
|
|
|
790
|
|
|
/** |
791
|
|
|
* Queries whether or not debug mode is enabled or not, default is TRUE. |
792
|
|
|
* |
793
|
|
|
* @return boolean TRUE if debug mode is enabled, else FALSE |
794
|
|
|
*/ |
795
|
|
|
public function isDebugMode() |
796
|
|
|
{ |
797
|
|
|
return $this->debugMode; |
798
|
|
|
} |
799
|
|
|
|
800
|
|
|
/** |
801
|
|
|
* Set's the log level to use. |
802
|
|
|
* |
803
|
|
|
* @param string $logLevel The log level to use |
804
|
|
|
* |
805
|
|
|
* @return void |
806
|
|
|
*/ |
807
|
|
|
public function setLogLevel($logLevel) |
808
|
|
|
{ |
809
|
|
|
$this->logLevel = $logLevel; |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
/** |
813
|
|
|
* Return's the log level to use. |
814
|
|
|
* |
815
|
|
|
* @return string The log level to use |
816
|
|
|
*/ |
817
|
|
|
public function getLogLevel() |
818
|
|
|
{ |
819
|
|
|
return $this->logLevel; |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
/** |
823
|
|
|
* Set's the explicit DB ID to use. |
824
|
|
|
* |
825
|
|
|
* @param string $useDbId The explicit DB ID to use |
826
|
|
|
* |
827
|
|
|
* @return void |
828
|
|
|
*/ |
829
|
|
|
public function setUseDbId($useDbId) |
830
|
|
|
{ |
831
|
|
|
$this->useDbId = $useDbId; |
832
|
|
|
} |
833
|
|
|
|
834
|
|
|
/** |
835
|
|
|
* Return's the explicit DB ID to use. |
836
|
|
|
* |
837
|
|
|
* @return string The explicit DB ID to use |
838
|
|
|
*/ |
839
|
|
|
public function getUseDbId() |
840
|
|
|
{ |
841
|
|
|
return $this->useDbId; |
842
|
|
|
} |
843
|
|
|
|
844
|
|
|
/** |
845
|
|
|
* Set's the PID filename to use. |
846
|
|
|
* |
847
|
|
|
* @param string $pidFilename The PID filename to use |
848
|
|
|
* |
849
|
|
|
* @return void |
850
|
|
|
*/ |
851
|
|
|
public function setPidFilename($pidFilename) |
852
|
|
|
{ |
853
|
|
|
$this->pidFilename = $pidFilename; |
854
|
|
|
} |
855
|
|
|
|
856
|
|
|
/** |
857
|
|
|
* Return's the PID filename to use. |
858
|
|
|
* |
859
|
|
|
* @return string The PID filename to use |
860
|
|
|
*/ |
861
|
|
|
public function getPidFilename() |
862
|
|
|
{ |
863
|
|
|
return $this->pidFilename; |
864
|
|
|
} |
865
|
|
|
|
866
|
|
|
/** |
867
|
|
|
* Set's the systemm name to be used. |
868
|
|
|
* |
869
|
|
|
* @param string $systemName The system name to be used |
870
|
|
|
* |
871
|
|
|
* @return void |
872
|
|
|
*/ |
873
|
|
|
public function setSystemName($systemName) |
874
|
|
|
{ |
875
|
|
|
$this->systemName = $systemName; |
876
|
|
|
} |
877
|
|
|
|
878
|
|
|
/** |
879
|
|
|
* Return's the systemm name to be used. |
880
|
|
|
* |
881
|
|
|
* @return string The system name to be used |
882
|
|
|
*/ |
883
|
|
|
public function getSystemName() |
884
|
|
|
{ |
885
|
|
|
return $this->systemName; |
886
|
|
|
} |
887
|
|
|
|
888
|
|
|
/** |
889
|
|
|
* Set's the collection with the path of the Magento Edition specific extension libraries. |
890
|
|
|
* |
891
|
|
|
* @param array $extensionLibraries The paths of the Magento Edition specific extension libraries |
892
|
|
|
* |
893
|
|
|
* @return void |
894
|
|
|
*/ |
895
|
|
|
public function setExtensionLibraries(array $extensionLibraries) |
896
|
|
|
{ |
897
|
|
|
$this->extensionLibraries = $extensionLibraries; |
898
|
|
|
} |
899
|
|
|
|
900
|
|
|
/** |
901
|
|
|
* Return's an array with the path of the Magento Edition specific extension libraries. |
902
|
|
|
* |
903
|
|
|
* @return array The paths of the Magento Edition specific extension libraries |
904
|
|
|
*/ |
905
|
|
|
public function getExtensionLibraries() |
906
|
|
|
{ |
907
|
|
|
return $this->extensionLibraries; |
908
|
|
|
} |
909
|
|
|
|
910
|
|
|
/** |
911
|
|
|
* Return's a collection with the path to additional vendor directories. |
912
|
|
|
* |
913
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The paths to additional vendor directories |
914
|
|
|
*/ |
915
|
|
|
public function getAdditionalVendorDirs() |
916
|
|
|
{ |
917
|
|
|
return $this->additionalVendorDirs; |
918
|
|
|
} |
919
|
|
|
} |
920
|
|
|
|