1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sylius\Component\Core\Model; |
13
|
|
|
|
14
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
15
|
|
|
use Doctrine\Common\Collections\Collection; |
16
|
|
|
use Sylius\Component\Addressing\Model\ZoneInterface; |
17
|
|
|
use Sylius\Component\Channel\Model\Channel as BaseChannel; |
18
|
|
|
use Sylius\Component\Currency\Model\CurrencyInterface; |
19
|
|
|
use Sylius\Component\Locale\Model\LocaleInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class Channel extends BaseChannel implements ChannelInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var CurrencyInterface |
28
|
|
|
*/ |
29
|
|
|
protected $defaultCurrency; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var LocaleInterface |
33
|
|
|
*/ |
34
|
|
|
protected $defaultLocale; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var ZoneInterface |
38
|
|
|
*/ |
39
|
|
|
protected $defaultTaxZone; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $taxCalculationStrategy; |
|
|
|
|
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var CurrencyInterface[]|Collection |
48
|
|
|
*/ |
49
|
|
|
protected $currencies; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var LocaleInterface[]|Collection |
53
|
|
|
*/ |
54
|
|
|
protected $locales; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var string |
58
|
|
|
*/ |
59
|
|
|
protected $themeName; |
60
|
|
|
|
61
|
|
|
public function __construct() |
62
|
|
|
{ |
63
|
|
|
parent::__construct(); |
64
|
|
|
|
65
|
|
|
$this->currencies = new ArrayCollection(); |
66
|
|
|
$this->locales = new ArrayCollection(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
|
|
public function getDefaultCurrency() |
73
|
|
|
{ |
74
|
|
|
return $this->defaultCurrency; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* {@inheritdoc} |
79
|
|
|
*/ |
80
|
|
|
public function setDefaultCurrency(CurrencyInterface $defaultCurrency) |
81
|
|
|
{ |
82
|
|
|
$this->defaultCurrency = $defaultCurrency; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* {@inheritdoc} |
87
|
|
|
*/ |
88
|
|
|
public function getDefaultLocale() |
89
|
|
|
{ |
90
|
|
|
return $this->defaultLocale; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* {@inheritdoc} |
95
|
|
|
*/ |
96
|
|
|
public function setDefaultLocale(LocaleInterface $defaultLocale) |
97
|
|
|
{ |
98
|
|
|
$this->defaultLocale = $defaultLocale; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* {@inheritdoc} |
103
|
|
|
*/ |
104
|
|
|
public function getDefaultTaxZone() |
105
|
|
|
{ |
106
|
|
|
return $this->defaultTaxZone; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* {@inheritdoc} |
111
|
|
|
*/ |
112
|
|
|
public function setDefaultTaxZone(ZoneInterface $defaultTaxZone = null) |
113
|
|
|
{ |
114
|
|
|
$this->defaultTaxZone = $defaultTaxZone; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* {@inheritdoc} |
119
|
|
|
*/ |
120
|
|
|
public function getTaxCalculationStrategy() |
121
|
|
|
{ |
122
|
|
|
return $this->taxCalculationStrategy; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* {@inheritdoc} |
127
|
|
|
*/ |
128
|
|
|
public function setTaxCalculationStrategy($taxCalculationStrategy) |
|
|
|
|
129
|
|
|
{ |
130
|
|
|
$this->taxCalculationStrategy = $taxCalculationStrategy; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* {@inheritdoc} |
135
|
|
|
*/ |
136
|
|
|
public function getCurrencies() |
137
|
|
|
{ |
138
|
|
|
return $this->currencies; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* {@inheritdoc} |
143
|
|
|
*/ |
144
|
|
|
public function addCurrency(CurrencyInterface $currency) |
145
|
|
|
{ |
146
|
|
|
if (!$this->hasCurrency($currency)) { |
147
|
|
|
$this->currencies->add($currency); |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* {@inheritdoc} |
153
|
|
|
*/ |
154
|
|
|
public function removeCurrency(CurrencyInterface $currency) |
155
|
|
|
{ |
156
|
|
|
if ($this->hasCurrency($currency)) { |
157
|
|
|
$this->currencies->removeElement($currency); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* {@inheritdoc} |
163
|
|
|
*/ |
164
|
|
|
public function hasCurrency(CurrencyInterface $currency) |
165
|
|
|
{ |
166
|
|
|
return $this->currencies->contains($currency); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* {@inheritdoc} |
171
|
|
|
*/ |
172
|
|
|
public function getLocales() |
173
|
|
|
{ |
174
|
|
|
return $this->locales; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* {@inheritdoc} |
179
|
|
|
*/ |
180
|
|
|
public function addLocale(LocaleInterface $locale) |
181
|
|
|
{ |
182
|
|
|
if (!$this->hasLocale($locale)) { |
183
|
|
|
$this->locales->add($locale); |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* {@inheritdoc} |
189
|
|
|
*/ |
190
|
|
|
public function removeLocale(LocaleInterface $locale) |
191
|
|
|
{ |
192
|
|
|
if ($this->hasLocale($locale)) { |
193
|
|
|
$this->locales->removeElement($locale); |
194
|
|
|
} |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* {@inheritdoc} |
199
|
|
|
*/ |
200
|
|
|
public function hasLocale(LocaleInterface $locale) |
201
|
|
|
{ |
202
|
|
|
return $this->locales->contains($locale); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* {@inheritdoc} |
207
|
|
|
*/ |
208
|
|
|
public function getThemeName() |
209
|
|
|
{ |
210
|
|
|
return $this->themeName; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* {@inheritdoc} |
215
|
|
|
*/ |
216
|
|
|
public function setThemeName($themeName) |
217
|
|
|
{ |
218
|
|
|
$this->themeName = $themeName; |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.