Completed
Push — 15.x ( d73106...00a1cc )
by Tim
01:24
created

Configuration::getOperationsToExecute()   B

Complexity

Conditions 7
Paths 12

Size

Total Lines 41

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 8.3306
c 0
b 0
f 0
cc 7
nc 12
nop 0

1 Method

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