1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Configuration\Jms\Configuration\Plugin |
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\Configuration; |
22
|
|
|
|
23
|
|
|
use JMS\Serializer\Annotation\Type; |
24
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
25
|
|
|
use JMS\Serializer\Annotation\PostDeserialize; |
26
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
27
|
|
|
use TechDivision\Import\ConfigurationInterface; |
28
|
|
|
use TechDivision\Import\Configuration\PluginConfigurationInterface; |
29
|
|
|
use TechDivision\Import\Configuration\ListenerAwareConfigurationInterface; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* A simple plugin configuration implementation. |
33
|
|
|
* |
34
|
|
|
* @author Tim Wagner <[email protected]> |
35
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
36
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
37
|
|
|
* @link https://github.com/techdivision/import-configuration-jms |
38
|
|
|
* @link http://www.techdivision.com |
39
|
|
|
*/ |
40
|
|
|
class Plugin implements PluginConfigurationInterface, ListenerAwareConfigurationInterface |
41
|
|
|
{ |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* The trait that provides parameter configuration functionality. |
45
|
|
|
* |
46
|
|
|
* @var \TechDivision\Import\Configuration\Jms\Configuration\ParamsTrait |
47
|
|
|
*/ |
48
|
|
|
use ParamsTrait; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Trait that provides CSV configuration functionality. |
52
|
|
|
* |
53
|
|
|
* @var \TechDivision\Import\Configuration\Jms\Configuration\ListenersTrait |
54
|
|
|
*/ |
55
|
|
|
use ListenersTrait; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* The main configuration. |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
protected $configuration; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* The plugin's unique DI identifier. |
66
|
|
|
* |
67
|
|
|
* @var string |
68
|
|
|
* @Type("string") |
69
|
|
|
* @SerializedName("id") |
70
|
|
|
*/ |
71
|
|
|
protected $id; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* The plugin's name. |
75
|
|
|
* |
76
|
|
|
* @var string |
77
|
|
|
* @Type("string") |
78
|
|
|
* @SerializedName("name") |
79
|
|
|
*/ |
80
|
|
|
protected $name; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* ArrayCollection with the information of the configured subjects. |
84
|
|
|
* |
85
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
86
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Configuration\Jms\Configuration\Subject>") |
87
|
|
|
*/ |
88
|
|
|
protected $subjects; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* The swift mailer configuration to use. |
92
|
|
|
* |
93
|
|
|
* @var \TechDivision\Import\Configuration\Jms\Configuration\SwiftMailer |
94
|
|
|
* @Type("TechDivision\Import\Configuration\Jms\Configuration\SwiftMailer") |
95
|
|
|
* @SerializedName("swift-mailer") |
96
|
|
|
*/ |
97
|
|
|
protected $swiftMailer; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Lifecycle callback that will be invoked after deserialization. |
101
|
|
|
* |
102
|
|
|
* @return void |
103
|
|
|
* @PostDeserialize |
104
|
|
|
*/ |
105
|
|
|
public function postDeserialize() |
106
|
|
|
{ |
107
|
|
|
|
108
|
|
|
// create an empty collection if no subjects has been specified |
109
|
|
|
if ($this->subjects === null) { |
110
|
|
|
$this->subjects = new ArrayCollection(); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Set's the reference to the configuration instance. |
116
|
|
|
* |
117
|
|
|
* @param \TechDivision\Import\ConfigurationInterface $configuration The configuration instance |
118
|
|
|
* |
119
|
|
|
* @return void |
120
|
|
|
*/ |
121
|
|
|
public function setConfiguration(ConfigurationInterface $configuration) |
122
|
|
|
{ |
123
|
|
|
$this->configuration = $configuration; |
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Return's the reference to the configuration instance. |
128
|
|
|
* |
129
|
|
|
* @return \TechDivision\Import\ConfigurationInterface The configuration instance |
130
|
|
|
*/ |
131
|
|
|
public function getConfiguration() |
132
|
|
|
{ |
133
|
|
|
return $this->configuration; |
|
|
|
|
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Return's the plugin's unique DI identifier. |
138
|
|
|
* |
139
|
|
|
* @return string The plugin's unique DI identifier |
140
|
|
|
*/ |
141
|
|
|
public function getId() |
142
|
|
|
{ |
143
|
|
|
return $this->id; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Return's the plugin's name or the ID, if the name is NOT set. |
148
|
|
|
* |
149
|
|
|
* @return string The plugin's name |
150
|
|
|
* @see \TechDivision\Import\Configuration\PluginConfigurationInterface::getId() |
151
|
|
|
*/ |
152
|
|
|
public function getName() |
153
|
|
|
{ |
154
|
|
|
return $this->name ? $this->name : $this->getId(); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Return's the ArrayCollection with the operation's subjects. |
159
|
|
|
* |
160
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the operation's subjects |
161
|
|
|
*/ |
162
|
|
|
public function getSubjects() |
163
|
|
|
{ |
164
|
|
|
|
165
|
|
|
// initialize the array with the subject configurations |
166
|
|
|
$subjects = array(); |
167
|
|
|
|
168
|
|
|
// iterate over the subject configurations |
169
|
|
|
foreach ($this->subjects as $subject) { |
170
|
|
|
// inject the parent plugin configuration |
171
|
|
|
$subject->setPluginConfiguration($this); |
172
|
|
|
// add the subject to the array |
173
|
|
|
$subjects[] = $subject; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
// return the array with subject configurations |
177
|
|
|
return $subjects; |
|
|
|
|
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Return's the swift mailer configuration to use. |
182
|
|
|
* |
183
|
|
|
* @return \TechDivision\Import\Configuration\Jms\Configuration\SwiftMailer The swift mailer configuration to use |
184
|
|
|
*/ |
185
|
|
|
public function getSwiftMailer() |
186
|
|
|
{ |
187
|
|
|
return $this->swiftMailer; |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..