1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Spryker\Zed\Discount; |
9
|
|
|
|
10
|
|
|
use Spryker\Zed\Kernel\AbstractBundleConfig; |
11
|
|
|
|
12
|
|
|
class DiscountConfig extends AbstractBundleConfig |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var int |
16
|
|
|
*/ |
17
|
|
|
public const DEFAULT_VOUCHER_CODE_LENGTH = 6; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var int |
21
|
|
|
*/ |
22
|
|
|
public const DEFAULT_MINIMUM_ITEM_AMOUNT = 1; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
public const KEY_VOUCHER_CODE_CONSONANTS = 'consonants'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
public const KEY_VOUCHER_CODE_VOWELS = 'vowels'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
public const KEY_VOUCHER_CODE_NUMBERS = 'numbers'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected const REDIRECT_URL_DEFAULT = '/discount/index/list'; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var int |
46
|
|
|
*/ |
47
|
|
|
protected const PRIORITY_MIN_VALUE = 1; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var int |
51
|
|
|
*/ |
52
|
|
|
protected const PRIORITY_MAX_VALUE = 9999; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var int |
56
|
|
|
*/ |
57
|
|
|
protected const VOUCHER_CODES_QUANTITY_MIN_VALUE = 1; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var int |
61
|
|
|
*/ |
62
|
|
|
protected const VOUCHER_CODES_QUANTITY_MAX_VALUE = 14000; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var bool |
66
|
|
|
*/ |
67
|
|
|
protected const IS_MONEY_COLLECTION_FORM_TYPE_PLUGIN_ENABLED = false; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @see https://en.wikipedia.org/wiki/Year_2038_problem |
71
|
|
|
* |
72
|
|
|
* @var string |
73
|
|
|
*/ |
74
|
|
|
protected const MAX_ALLOWED_DATETIME = '2038-01-19 03:14:07'; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @api |
78
|
|
|
* |
79
|
|
|
* @return int |
80
|
|
|
*/ |
81
|
|
|
public function getVoucherCodeLength() |
82
|
|
|
{ |
83
|
|
|
return static::DEFAULT_VOUCHER_CODE_LENGTH; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @api |
88
|
|
|
* |
89
|
|
|
* @return array<string, array<mixed>> |
90
|
|
|
*/ |
91
|
|
|
public function getVoucherCodeCharacters() |
92
|
|
|
{ |
93
|
|
|
return [ |
94
|
|
|
static::KEY_VOUCHER_CODE_CONSONANTS => [ |
95
|
|
|
'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', |
96
|
|
|
], |
97
|
|
|
static::KEY_VOUCHER_CODE_VOWELS => [ |
98
|
|
|
'a', 'e', 'u', |
99
|
|
|
], |
100
|
|
|
static::KEY_VOUCHER_CODE_NUMBERS => [ |
101
|
|
|
1, 2, 3, 4, 5, 6, 7, 8, 9, |
102
|
|
|
], |
103
|
|
|
]; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @api |
108
|
|
|
* |
109
|
|
|
* @return int |
110
|
|
|
*/ |
111
|
|
|
public function getAllowedCodeCharactersLength() |
112
|
|
|
{ |
113
|
|
|
/** @var int $charactersLength */ |
114
|
|
|
$charactersLength = array_reduce($this->getVoucherCodeCharacters(), function ($length, $items) { |
115
|
|
|
$length += count($items); |
116
|
|
|
|
117
|
|
|
return $length; |
118
|
|
|
}); |
119
|
|
|
|
120
|
|
|
return $charactersLength; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @api |
125
|
|
|
* |
126
|
|
|
* @return string |
127
|
|
|
*/ |
128
|
|
|
public function getVoucherPoolTemplateReplacementString() |
129
|
|
|
{ |
130
|
|
|
return '[code]'; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @api |
135
|
|
|
* |
136
|
|
|
* @return string |
137
|
|
|
*/ |
138
|
|
|
public function getDefaultRedirectUrl(): string |
139
|
|
|
{ |
140
|
|
|
return static::REDIRECT_URL_DEFAULT; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Specification: |
145
|
|
|
* - Defines the minimum numeric value for priority (the highest possible priority). |
146
|
|
|
* |
147
|
|
|
* @api |
148
|
|
|
* |
149
|
|
|
* @return int |
150
|
|
|
*/ |
151
|
|
|
public function getPriorityMinValue(): int |
152
|
|
|
{ |
153
|
|
|
return static::PRIORITY_MIN_VALUE; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Specification: |
158
|
|
|
* - Defines the maximum numeric value for priority (the lowest possible priority). |
159
|
|
|
* |
160
|
|
|
* @api |
161
|
|
|
* |
162
|
|
|
* @return int |
163
|
|
|
*/ |
164
|
|
|
public function getPriorityMaxValue(): int |
165
|
|
|
{ |
166
|
|
|
return static::PRIORITY_MAX_VALUE; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Specification: |
171
|
|
|
* - Defines the minimum quantity of generated voucher codes. |
172
|
|
|
* |
173
|
|
|
* @api |
174
|
|
|
* |
175
|
|
|
* @return int |
176
|
|
|
*/ |
177
|
|
|
public function getVoucherCodesQuantityMinValue(): int |
178
|
|
|
{ |
179
|
|
|
return static::VOUCHER_CODES_QUANTITY_MIN_VALUE; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Specification: |
184
|
|
|
* - Defines the maximum quantity of generated voucher codes. |
185
|
|
|
* |
186
|
|
|
* @api |
187
|
|
|
* |
188
|
|
|
* @return int |
189
|
|
|
*/ |
190
|
|
|
public function getVoucherCodesQuantityMaxValue(): int |
191
|
|
|
{ |
192
|
|
|
return static::VOUCHER_CODES_QUANTITY_MAX_VALUE; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Specification: |
197
|
|
|
* - Enables using money collection form type plugin. |
198
|
|
|
* |
199
|
|
|
* @api |
200
|
|
|
* |
201
|
|
|
* @return bool |
202
|
|
|
*/ |
203
|
|
|
public function isMoneyCollectionFormTypePluginEnabled(): bool |
204
|
|
|
{ |
205
|
|
|
return static::IS_MONEY_COLLECTION_FORM_TYPE_PLUGIN_ENABLED; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* Specification: |
210
|
|
|
* - Defines the maximum datetime value that can be used for timestamps columns. |
211
|
|
|
* |
212
|
|
|
* @api |
213
|
|
|
* |
214
|
|
|
* @return string |
215
|
|
|
*/ |
216
|
|
|
public function getMaxAllowedDatetime(): string |
217
|
|
|
{ |
218
|
|
|
return static::MAX_ALLOWED_DATETIME; |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
|