Completed
Push — 15.x ( 00a1cc...df859a )
by Tim
01:21
created

Configuration::setCompile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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