1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Mathielen\ImportEngine\ValueObject; |
4
|
|
|
|
5
|
|
|
class ImportConfiguration |
6
|
|
|
{ |
7
|
|
|
private $importerId = null; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @var StorageSelection |
11
|
|
|
*/ |
12
|
|
|
private $sourceStorageSelection; |
13
|
|
|
|
14
|
18 |
|
public function __construct(StorageSelection $sourceStorageSelection = null, $importerId = null) |
15
|
|
|
{ |
16
|
18 |
|
if ($importerId) { |
17
|
1 |
|
$this->setImporterId($importerId); |
18
|
|
|
} |
19
|
18 |
|
if ($sourceStorageSelection) { |
20
|
1 |
|
$this->setSourceStorageSelection($sourceStorageSelection); |
21
|
|
|
} |
22
|
18 |
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @return ImportConfiguration |
26
|
|
|
*/ |
27
|
1 |
|
public function setSourceStorageSelection(StorageSelection $sourceStorageSelection) |
28
|
|
|
{ |
29
|
1 |
|
$this->sourceStorageSelection = $sourceStorageSelection; |
30
|
|
|
|
31
|
1 |
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return StorageSelection |
36
|
|
|
*/ |
37
|
|
|
public function getSourceStorageSelection() |
38
|
|
|
{ |
39
|
|
|
return $this->sourceStorageSelection; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return ImportConfiguration |
44
|
|
|
*/ |
45
|
1 |
|
public function setImporterId($importerId) |
46
|
|
|
{ |
47
|
1 |
|
if (empty($importerId)) { |
48
|
|
|
throw new \InvalidArgumentException('importerId must be given'); |
49
|
|
|
} |
50
|
|
|
|
51
|
1 |
|
$this->importerId = $importerId; |
52
|
|
|
|
53
|
1 |
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
1 |
|
public function getImporterId() |
57
|
|
|
{ |
58
|
1 |
|
return $this->importerId; |
59
|
|
|
} |
60
|
|
|
|
61
|
8 |
|
public function toArray() |
62
|
|
|
{ |
63
|
|
|
return array( |
64
|
8 |
|
'importerid' => $this->importerId, |
65
|
8 |
|
'sourcestorageselection' => $this->sourceStorageSelection ? array( |
66
|
|
|
'name' => $this->sourceStorageSelection->getName(), |
67
|
|
|
'id' => $this->sourceStorageSelection->getId(), |
68
|
|
|
) : null, |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return ImportRun |
74
|
|
|
*/ |
75
|
9 |
|
public function toRun($createdBy = null) |
76
|
|
|
{ |
77
|
9 |
|
return new ImportRun($this, $createdBy); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|