Completed
Push — 8.x ( 41ca52 )
by Tim
10:18
created

Configuration::setPidFilename()   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 JMS\Serializer\Annotation\Type;
25
use JMS\Serializer\Annotation\Exclude;
26
use JMS\Serializer\Annotation\SerializedName;
27
use JMS\Serializer\Annotation\PostDeserialize;
28
use JMS\Serializer\Annotation\ExclusionPolicy;
29
use Doctrine\Common\Collections\ArrayCollection;
30
use TechDivision\Import\ConfigurationInterface;
31
use TechDivision\Import\Configuration\DatabaseConfigurationInterface;
32
use TechDivision\Import\Configuration\Jms\Configuration\Operation;
33
use TechDivision\Import\Configuration\Jms\Configuration\ParamsTrait;
34
use TechDivision\Import\Configuration\Jms\Configuration\CsvTrait;
35
use TechDivision\Import\Configuration\Jms\Configuration\ListenersTrait;
36
37
/**
38
 * A simple JMS based configuration implementation.
39
 *
40
 * @author    Tim Wagner <[email protected]>
41
 * @copyright 2016 TechDivision GmbH <[email protected]>
42
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
43
 * @link      https://github.com/techdivision/import-configuration-jms
44
 * @link      http://www.techdivision.com
45
 *
46
 * @ExclusionPolicy("none")
47
 */
48
class Configuration implements ConfigurationInterface
49
{
50
51
    /**
52
     * The default PID filename to use.
53
     *
54
     * @var string
55
     */
56
    const PID_FILENAME = 'importer.pid';
57
58
    /**
59
     * Trait that provides CSV configuration functionality.
60
     *
61
     * @var \TechDivision\Import\Configuration\Jms\Configuration\CsvTrait
62
     */
63
    use CsvTrait;
64
65
    /**
66
     * Trait that provides CSV configuration functionality.
67
     *
68
     * @var \TechDivision\Import\Configuration\Jms\Configuration\ParamsTrait
69
     */
70
    use ParamsTrait;
71
72
    /**
73
     * Trait that provides CSV configuration functionality.
74
     *
75
     * @var \TechDivision\Import\Configuration\Jms\Configuration\ListenersTrait
76
     */
77
    use ListenersTrait;
78
79
    /**
80
     * Mapping for boolean values passed on the console.
81
     *
82
     * @var array
83
     * @Exclude
84
     */
85
    protected $booleanMapping = array(
86
        'true'  => true,
87
        'false' => false,
88
        '1'     => true,
89
        '0'     => false,
90
        'on'    => true,
91
        'off'   => false
92
    );
93
94
    /**
95
     * The application's unique DI identifier.
96
     *
97
     * @var string
98
     * @Type("string")
99
     * @SerializedName("id")
100
     */
101
    protected $id;
102
103
    /**
104
     * The system name to use.
105
     *
106
     * @var string
107
     * @Type("string")
108
     * @SerializedName("system-name")
109
     */
110
    protected $systemName;
111
112
    /**
113
     * The operation name to use.
114
     *
115
     * @var string
116
     * @Type("string")
117
     * @SerializedName("operation-name")
118
     */
119
    protected $operationName;
120
121
    /**
122
     * The entity type code to use.
123
     *
124
     * @var string
125
     * @Type("string")
126
     * @SerializedName("entity-type-code")
127
     */
128
    protected $entityTypeCode;
129
130
    /**
131
     * The Magento installation directory.
132
     *
133
     * @var string
134
     * @Type("string")
135
     * @SerializedName("installation-dir")
136
     */
137
    protected $installationDir;
138
139
    /**
140
     * The source directory that has to be watched for new files.
141
     *
142
     * @var string
143
     * @Type("string")
144
     * @SerializedName("source-dir")
145
     */
146
    protected $sourceDir;
147
148
    /**
149
     * The target directory with the files that has been imported.
150
     *
151
     * @var string
152
     * @Type("string")
153
     * @SerializedName("target-dir")
154
     */
155
    protected $targetDir;
156
157
    /**
158
     * The Magento edition, EE or CE.
159
     *
160
     * @var string
161
     * @Type("string")
162
     * @SerializedName("magento-edition")
163
     */
164
    protected $magentoEdition = 'CE';
165
166
    /**
167
     * The Magento version, e. g. 2.1.0.
168
     *
169
     * @var string
170
     * @Type("string")
171
     * @SerializedName("magento-version")
172
     */
173
    protected $magentoVersion = '2.1.2';
174
175
    /**
176
     * ArrayCollection with the information of the configured databases.
177
     *
178
     * @var \Doctrine\Common\Collections\ArrayCollection
179
     * @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Database>")
180
     */
181
    protected $databases;
182
183
    /**
184
     * ArrayCollection with the information of the configured loggers.
185
     *
186
     * @var \Doctrine\Common\Collections\ArrayCollection
187
     * @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Logger>")
188
     */
189
    protected $loggers;
190
191
    /**
192
     * ArrayCollection with the information of the configured operations.
193
     *
194
     * @var \Doctrine\Common\Collections\ArrayCollection
195
     * @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Operation>")
196
     */
197
    protected $operations;
198
199
    /**
200
     * The subject's multiple field delimiter character for fields with multiple values, defaults to (,).
201
     *
202
     * @var string
203
     * @Type("string")
204
     * @SerializedName("multiple-field-delimiter")
205
     */
206
    protected $multipleFieldDelimiter = ',';
207
208
    /**
209
     * The subject's multiple value delimiter character for fields with multiple values, defaults to (|).
210
     *
211
     * @var string
212
     * @Type("string")
213
     * @SerializedName("multiple-value-delimiter")
214
     */
215
    protected $multipleValueDelimiter = '|';
216
217
    /**
218
     * The flag to signal that the subject has to use the strict mode or not.
219
     *
220
     * @var boolean
221
     * @Type("boolean")
222
     * @SerializedName("strict-mode")
223
     */
224
    protected $strictMode;
225
226
    /**
227
     * The flag whether or not the import artefacts have to be archived.
228
     *
229
     * @var boolean
230
     * @Type("boolean")
231
     * @SerializedName("archive-artefacts")
232
     */
233
    protected $archiveArtefacts;
234
235
    /**
236
     * The directory where the archives will be stored.
237
     *
238
     * @var string
239
     * @Type("string")
240
     * @SerializedName("archive-dir")
241
     */
242
    protected $archiveDir;
243
244
    /**
245
     * The flag to signal that the subject has to use the debug mode or not.
246
     *
247
     * @var boolean
248
     * @Type("boolean")
249
     * @SerializedName("debug-mode")
250
     */
251
    protected $debugMode = false;
252
253
    /**
254
     * The log level to use (see Monolog documentation).
255
     *
256
     * @var string
257
     * @Type("string")
258
     * @SerializedName("log-level")
259
     */
260
    protected $logLevel = LogLevel::INFO;
261
262
    /**
263
     * The explicit DB ID to use.
264
     *
265
     * @var string
266
     * @Type("string")
267
     * @SerializedName("use-db-id")
268
     */
269
    protected $useDbId;
270
271
    /**
272
     * The explicit PID filename to use.
273
     *
274
     * @var string
275
     * @Type("string")
276
     * @SerializedName("pid-filename")
277
     */
278
    protected $pidFilename;
279
280
    /**
281
     * The collection with the paths to additional vendor directories.
282
     *
283
     * @var \Doctrine\Common\Collections\ArrayCollection
284
     * @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\VendorDir>")
285
     * @SerializedName("additional-vendor-dirs")
286
     */
287
    protected $additionalVendorDirs;
288
289
    /**
290
     * The array with the Magento Edition specific extension libraries.
291
     *
292
     * @var array
293
     * @Type("array")
294
     * @SerializedName("extension-libraries")
295
     */
296
    protected $extensionLibraries = array();
297
298
    /**
299
     * The array with the custom header mappings.
300
     *
301
     * @var array
302
     * @Type("array")
303
     * @SerializedName("header-mappings")
304
     */
305
    protected $headerMappings = array();
306
307
    /**
308
     * The array with the custom image types.
309
     *
310
     * @var array
311
     * @Type("array")
312
     * @SerializedName("image-types")
313
     */
314
    protected $imageTypes = array();
315
316
    /**
317
     * The flag to signal that the should be wrapped within a single transation or not.
318
     *
319
     * @var boolean
320
     * @Type("boolean")
321
     * @SerializedName("single-transaction")
322
     */
323
    protected $singleTransaction = false;
324
325
    /**
326
     * Return's the array with the plugins of the operation to use.
327
     *
328
     * @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the plugins
329
     * @throws \Exception Is thrown, if no plugins are available for the actual operation
330
     */
331
    public function getPlugins()
332
    {
333
334
        // iterate over the operations and return the subjects of the actual one
335
        /** @var TechDivision\Import\Configuration\OperationInterface $operation */
336
        foreach ($this->getOperations() as $operation) {
337
            if ($this->getOperation()->equals($operation)) {
338
                return $operation->getPlugins();
339
            }
340
        }
341
342
        // throw an exception if no plugins are available
343
        throw new \Exception(sprintf('Can\'t find any plugins for operation %s', $this->getOperation()));
344
    }
345
346
    /**
347
     * Map's the passed value to a boolean.
348
     *
349
     * @param string $value The value to map
350
     *
351
     * @return boolean The mapped value
352
     * @throws \Exception Is thrown, if the value can't be mapped
353
     */
354
    public function mapBoolean($value)
355
    {
356
357
        // try to map the passed value to a boolean
358
        if (isset($this->booleanMapping[$value])) {
359
            return $this->booleanMapping[$value];
360
        }
361
362
        // throw an exception if we can't convert the passed value
363
        throw new \Exception(sprintf('Can\'t convert %s to boolean', $value));
364
    }
365
366
    /**
367
     * Return's the operation, initialize from the actual operation name.
368
     *
369
     * @return \TechDivision\Import\Configuration\OperationConfigurationInterface The operation instance
370
     */
371
    public function getOperation()
372
    {
373
        return new Operation($this->getOperationName());
374
    }
375
376
    /**
377
     * Return's the application's unique DI identifier.
378
     *
379
     * @return string The application's unique DI identifier
380
     */
381
    public function getId()
382
    {
383
        return $this->id;
384
    }
385
386
    /**
387
     * Return's the operation name that has to be used.
388
     *
389
     * @param string $operationName The operation name that has to be used
390
     *
391
     * @return void
392
     */
393
    public function setOperationName($operationName)
394
    {
395
        return $this->operationName = $operationName;
396
    }
397
398
    /**
399
     * Return's the operation name that has to be used.
400
     *
401
     * @return string The operation name that has to be used
402
     */
403
    public function getOperationName()
404
    {
405
        return $this->operationName;
406
    }
407
408
    /**
409
     * Set's the Magento installation directory.
410
     *
411
     * @param string $installationDir The Magento installation directory
412
     *
413
     * @return void
414
     */
415
    public function setInstallationDir($installationDir)
416
    {
417
        $this->installationDir = $installationDir;
418
    }
419
420
    /**
421
     * Return's the Magento installation directory.
422
     *
423
     * @return string The Magento installation directory
424
     */
425
    public function getInstallationDir()
426
    {
427
        return $this->installationDir;
428
    }
429
430
    /**
431
     * Set's the source directory that has to be watched for new files.
432
     *
433
     * @param string $sourceDir The source directory
434
     *
435
     * @return void
436
     */
437
    public function setSourceDir($sourceDir)
438
    {
439
        $this->sourceDir = $sourceDir;
440
    }
441
442
    /**
443
     * Return's the source directory that has to be watched for new files.
444
     *
445
     * @return string The source directory
446
     */
447
    public function getSourceDir()
448
    {
449
        return $this->sourceDir;
450
    }
451
452
    /**
453
     * Set's the target directory with the files that has been imported.
454
     *
455
     * @param string $targetDir The target directory
456
     *
457
     * @return void
458
     */
459
    public function setTargetDir($targetDir)
460
    {
461
        $this->targetDir = $targetDir;
462
    }
463
464
    /**
465
     * Return's the target directory with the files that has been imported.
466
     *
467
     * @return string The target directory
468
     */
469
    public function getTargetDir()
470
    {
471
        return $this->targetDir;
472
    }
473
474
    /**
475
     * Set's the Magento edition, EE or CE.
476
     *
477
     * @param string $magentoEdition The Magento edition
478
     *
479
     * @return void
480
     */
481
    public function setMagentoEdition($magentoEdition)
482
    {
483
        $this->magentoEdition = $magentoEdition;
484
    }
485
486
    /**
487
     * Return's the Magento edition, EE or CE.
488
     *
489
     * @return string The Magento edition
490
     */
491
    public function getMagentoEdition()
492
    {
493
        return $this->magentoEdition;
494
    }
495
496
    /**
497
     * Return's the Magento version, e. g. 2.1.0.
498
     *
499
     * @param string $magentoVersion The Magento version
500
     *
501
     * @return void
502
     */
503
    public function setMagentoVersion($magentoVersion)
504
    {
505
        $this->magentoVersion = $magentoVersion;
506
    }
507
508
    /**
509
     * Return's the Magento version, e. g. 2.1.0.
510
     *
511
     * @return string The Magento version
512
     */
513
    public function getMagentoVersion()
514
    {
515
        return $this->magentoVersion;
516
    }
517
518
    /**
519
     * Set's the subject's source date format to use.
520
     *
521
     * @param string $sourceDateFormat The source date format
522
     *
523
     * @return void
524
     */
525
    public function setSourceDateFormat($sourceDateFormat)
526
    {
527
        $this->sourceDateFormat = $sourceDateFormat;
0 ignored issues
show
Bug introduced by
The property sourceDateFormat does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
528
    }
529
530
    /**
531
     * Return's the entity type code to be used.
532
     *
533
     * @return string The entity type code to be used
534
     */
535
    public function getEntityTypeCode()
536
    {
537
        return $this->entityTypeCode;
538
    }
539
540
    /**
541
     * Set's the entity type code to be used.
542
     *
543
     * @param string $entityTypeCode The entity type code
544
     *
545
     * @return void
546
     */
547
    public function setEntityTypeCode($entityTypeCode)
548
    {
549
        $this->entityTypeCode = $entityTypeCode;
550
    }
551
552
    /**
553
     * Return's the multiple field delimiter character to use, default value is comma (,).
554
     *
555
     * @return string The multiple field delimiter character
556
     */
557
    public function getMultipleFieldDelimiter()
558
    {
559
        return $this->multipleFieldDelimiter;
560
    }
561
562
    /**
563
     * Return's the multiple value delimiter character to use, default value is comma (|).
564
     *
565
     * @return string The multiple value delimiter character
566
     */
567
    public function getMultipleValueDelimiter()
568
    {
569
        return $this->multipleValueDelimiter;
570
    }
571
572
    /**
573
     * Queries whether or not strict mode is enabled or not, default is TRUE.
574
     *
575
     * @return boolean TRUE if strict mode is enabled, else FALSE
576
     */
577
    public function isStrictMode()
578
    {
579
        return $this->strictMode;
580
    }
581
582
    /**
583
     * Remove's all configured database configuration.
584
     *
585
     * @return void
586
     */
587
    public function clearDatabases()
588
    {
589
        $this->databases->clear();
590
    }
591
592
    /**
593
     * Add's the passed database configuration.
594
     *
595
     * @param \TechDivision\Import\Configuration\DatabaseConfigurationInterface $database The database configuration
596
     *
597
     * @return void
598
     */
599
    public function addDatabase(DatabaseConfigurationInterface $database)
600
    {
601
        $this->databases->add($database);
602
    }
603
604
    /**
605
     * Return's the number database configurations.
606
     *
607
     * @return integer The number of database configurations
608
     */
609
    public function countDatabases()
610
    {
611
        return $this->databases->count();
612
    }
613
614
    /**
615
     * Return's the database configuration with the passed ID.
616
     *
617
     * @param string $id The ID of the database connection to return
618
     *
619
     * @return \TechDivision\Import\Configuration\DatabaseConfigurationInterface The database configuration
620
     * @throws \Exception Is thrown, if no database configuration is available
621
     */
622
    public function getDatabaseById($id)
623
    {
624
625
        // iterate over the configured databases and return the one with the passed ID
626
        /** @var TechDivision\Import\Configuration\DatabaseInterface  $database */
627
        foreach ($this->databases as $database) {
628
            if ($database->getId() === $id) {
629
                return $database;
630
            }
631
        }
632
633
        // throw an exception, if the database with the passed ID is NOT configured
634
        throw new \Exception(sprintf('Database with ID %s can not be found', $id));
635
    }
636
637
    /**
638
     * Return's the database configuration.
639
     *
640
     * If an explicit DB ID is specified, the method tries to return the database with this ID. If
641
     * the database configuration is NOT available, an execption is thrown.
642
     *
643
     * If no explicit DB ID is specified, the method tries to return the default database configuration,
644
     * if not available the first one.
645
     *
646
     * @return \TechDivision\Import\Configuration\DatabaseConfigurationInterface The database configuration
647
     * @throws \Exception Is thrown, if no database configuration is available
648
     */
649
    public function getDatabase()
650
    {
651
652
        // if a DB ID has been set, try to load the database
653
        if ($useDbId = $this->getUseDbId()) {
654
            return $this->getDatabaseById($useDbId);
655
        }
656
657
        // iterate over the configured databases and try return the default database
658
        /** @var TechDivision\Import\Configuration\DatabaseInterface  $database */
659
        foreach ($this->databases as $database) {
660
            if ($database->isDefault()) {
661
                return $database;
662
            }
663
        }
664
665
        // try to return the first database configurtion
666
        if ($this->databases->count() > 0) {
667
            return $this->databases->first();
668
        }
669
670
        // throw an exception, if no database configuration is available
671
        throw new \Exception('There is no database configuration available');
672
    }
673
674
    /**
675
     * Return's the ArrayCollection with the configured operations.
676
     *
677
     * @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the operations
678
     */
679
    public function getOperations()
680
    {
681
        return $this->operations;
682
    }
683
684
    /**
685
     * Return's the ArrayCollection with the configured loggers.
686
     *
687
     * @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the loggers
688
     */
689
    public function getLoggers()
690
    {
691
        return $this->loggers;
692
    }
693
694
    /**
695
     * Set's the flag that import artefacts have to be archived or not.
696
     *
697
     * @param boolean $archiveArtefacts TRUE if artefacts have to be archived, else FALSE
698
     *
699
     * @return void
700
     */
701
    public function setArchiveArtefacts($archiveArtefacts)
702
    {
703
        $this->archiveArtefacts = $archiveArtefacts;
704
    }
705
706
    /**
707
     * Return's the TRUE if the import artefacts have to be archived.
708
     *
709
     * @return boolean TRUE if the import artefacts have to be archived
710
     */
711
    public function haveArchiveArtefacts()
712
    {
713
        return $this->archiveArtefacts;
714
    }
715
716
    /**
717
     * The directory where the archives will be stored.
718
     *
719
     * @param string $archiveDir The archive directory
720
     *
721
     * @return void
722
     */
723
    public function setArchiveDir($archiveDir)
724
    {
725
        $this->archiveDir = $archiveDir;
726
    }
727
728
    /**
729
     * The directory where the archives will be stored.
730
     *
731
     * @return string The archive directory
732
     */
733
    public function getArchiveDir()
734
    {
735
        return $this->archiveDir;
736
    }
737
738
    /**
739
     * Set's the debug mode.
740
     *
741
     * @param boolean $debugMode TRUE if debug mode is enabled, else FALSE
742
     *
743
     * @return void
744
     */
745
    public function setDebugMode($debugMode)
746
    {
747
        $this->debugMode = $debugMode;
748
    }
749
750
    /**
751
     * Queries whether or not debug mode is enabled or not, default is TRUE.
752
     *
753
     * @return boolean TRUE if debug mode is enabled, else FALSE
754
     */
755
    public function isDebugMode()
756
    {
757
        return $this->debugMode;
758
    }
759
760
    /**
761
     * Set's the log level to use.
762
     *
763
     * @param string $logLevel The log level to use
764
     *
765
     * @return void
766
     */
767
    public function setLogLevel($logLevel)
768
    {
769
        $this->logLevel = $logLevel;
770
    }
771
772
    /**
773
     * Return's the log level to use.
774
     *
775
     * @return string The log level to use
776
     */
777
    public function getLogLevel()
778
    {
779
        return $this->logLevel;
780
    }
781
782
    /**
783
     * Set's the explicit DB ID to use.
784
     *
785
     * @param string $useDbId The explicit DB ID to use
786
     *
787
     * @return void
788
     */
789
    public function setUseDbId($useDbId)
790
    {
791
        $this->useDbId = $useDbId;
792
    }
793
794
    /**
795
     * Return's the explicit DB ID to use.
796
     *
797
     * @return string The explicit DB ID to use
798
     */
799
    public function getUseDbId()
800
    {
801
        return $this->useDbId;
802
    }
803
804
    /**
805
     * Set's the PID filename to use.
806
     *
807
     * @param string $pidFilename The PID filename to use
808
     *
809
     * @return void
810
     */
811
    public function setPidFilename($pidFilename)
812
    {
813
        $this->pidFilename = $pidFilename;
814
    }
815
816
    /**
817
     * Return's the PID filename to use.
818
     *
819
     * @return string The PID filename to use
820
     */
821
    public function getPidFilename()
822
    {
823
        return $this->pidFilename;
824
    }
825
826
    /**
827
     * Set's the systemm name to be used.
828
     *
829
     * @param string $systemName The system name to be used
830
     *
831
     * @return void
832
     */
833
    public function setSystemName($systemName)
834
    {
835
        $this->systemName = $systemName;
836
    }
837
838
    /**
839
     * Return's the systemm name to be used.
840
     *
841
     * @return string The system name to be used
842
     */
843
    public function getSystemName()
844
    {
845
        return $this->systemName;
846
    }
847
848
    /**
849
     * Set's the collection with the path of the Magento Edition specific extension libraries.
850
     *
851
     * @param array $extensionLibraries The paths of the Magento Edition specific extension libraries
852
     *
853
     * @return void
854
     */
855
    public function setExtensionLibraries(array $extensionLibraries)
856
    {
857
        $this->extensionLibraries = $extensionLibraries;
858
    }
859
860
    /**
861
     * Return's an array with the path of the Magento Edition specific extension libraries.
862
     *
863
     * @return array The paths of the Magento Edition specific extension libraries
864
     */
865
    public function getExtensionLibraries()
866
    {
867
        return $this->extensionLibraries;
868
    }
869
870
    /**
871
     * Return's a collection with the path to additional vendor directories.
872
     *
873
     * @return \Doctrine\Common\Collections\ArrayCollection The paths to additional vendor directories
874
     */
875
    public function getAdditionalVendorDirs()
876
    {
877
        return $this->additionalVendorDirs;
878
    }
879
880
    /**
881
     * Lifecycle callback that will be invoked after deserialization.
882
     *
883
     * @return void
884
     * @PostDeserialize
885
     */
886
    public function postDeserialize()
887
    {
888
889
        // create an empty collection if no operations has been specified
890
        if ($this->loggers === null) {
891
            $this->loggers = new ArrayCollection();
892
        }
893
894
        // create an empty collection if no operations has been specified
895
        if ($this->operations === null) {
896
            $this->operations = new ArrayCollection();
897
        }
898
899
        // create an empty collection if no loggers has been specified
900
        if ($this->additionalVendorDirs === null) {
901
            $this->additionalVendorDirs = new ArrayCollection();
902
        }
903
    }
904
905
    /**
906
     * The array with the subject's custom header mappings.
907
     *
908
     * @return array The custom header mappings
909
     */
910
    public function getHeaderMappings()
911
    {
912
913
        // initialize the array for the custom header mappings
914
        $headerMappings = array();
915
916
        // try to load the configured header mappings
917
        if ($headerMappingsAvailable = reset($this->headerMappings)) {
918
            $headerMappings = $headerMappingsAvailable;
919
        }
920
921
        // return the custom header mappings
922
        return $headerMappings;
923
    }
924
925
    /**
926
     * The array with the subject's custom image types.
927
     *
928
     * @return array The custom image types
929
     */
930
    public function getImageTypes()
931
    {
932
933
        // initialize the array for the custom image types
934
        $imageTypes = array();
935
936
        // try to load the configured image types
937
        if ($imageTypesAvailable = reset($this->imageTypes)) {
938
            $imageTypes = $imageTypesAvailable;
939
        }
940
941
        // return the custom image types
942
        return $imageTypes;
943
    }
944
945
    /**
946
     * Set's the flag that decides whether or not the import should be wrapped within a single transaction.
947
     *
948
     * @param boolean $singleTransaction TRUE if the import should be wrapped in a single transation, else FALSE
949
     *
950
     * @return void
951
     */
952
    public function setSingleTransaction($singleTransaction)
953
    {
954
        $this->singleTransaction = $singleTransaction;
955
    }
956
957
    /**
958
     * Whether or not the import should be wrapped within a single transation.
959
     *
960
     * @return boolean TRUE if the import should be wrapped in a single transation, else FALSE
961
     */
962
    public function isSingleTransaction()
963
    {
964
        return $this->singleTransaction;
965
    }
966
}
967