3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Deploy \Console ;
7
8
8
- use Magento \ Setup \ Console \ Command \ DeployStaticContentCommand ;
9
+ use InvalidArgumentException ;
9
10
use Magento \Deploy \Console \DeployStaticOptions as Options ;
10
- use Magento \Framework \Validator \Locale ;
11
- use Symfony \Component \Console \Input \InputInterface ;
12
11
use Magento \Framework \App \ObjectManager ;
12
+ use Magento \Framework \Validator \Locale ;
13
13
use Magento \Framework \Validator \RegexFactory ;
14
+ use Symfony \Component \Console \Input \InputInterface ;
15
+ use function array_key_exists ;
14
16
15
17
/**
16
18
* Command input arguments validator class
@@ -66,7 +68,7 @@ class InputValidator
66
68
* InputValidator constructor
67
69
*
68
70
* @param Locale $localeValidator
69
- * @param RegexFactory $versionValidatorFactory
71
+ * @param RegexFactory|null $versionValidatorFactory
70
72
*/
71
73
public function __construct (
72
74
Locale $ localeValidator ,
@@ -100,6 +102,10 @@ public function validate(InputInterface $input)
100
102
$ this ->checkVersionInput (
101
103
$ input ->getOption (Options::CONTENT_VERSION ) ?: ''
102
104
);
105
+ $ this ->checkNoParentInput (
106
+ (bool )$ input ->getOption (Options::NO_PARENT ),
107
+ (string )$ input ->getOption (Options::STRATEGY )
108
+ );
103
109
}
104
110
105
111
/**
@@ -108,12 +114,12 @@ public function validate(InputInterface $input)
108
114
* @param array $areasInclude
109
115
* @param array $areasExclude
110
116
* @return void
111
- * @throws \ InvalidArgumentException
117
+ * @throws InvalidArgumentException
112
118
*/
113
119
private function checkAreasInput (array $ areasInclude , array $ areasExclude )
114
120
{
115
- if ($ areasInclude [0 ] != 'all ' && $ areasExclude [0 ] != 'none ' ) {
116
- throw new \ InvalidArgumentException (
121
+ if ($ areasInclude [0 ] !== 'all ' && $ areasExclude [0 ] != = 'none ' ) {
122
+ throw new InvalidArgumentException (
117
123
'--area (-a) and --exclude-area cannot be used at the same time '
118
124
);
119
125
}
@@ -125,12 +131,12 @@ private function checkAreasInput(array $areasInclude, array $areasExclude)
125
131
* @param array $themesInclude
126
132
* @param array $themesExclude
127
133
* @return void
128
- * @throws \ InvalidArgumentException
134
+ * @throws InvalidArgumentException
129
135
*/
130
136
private function checkThemesInput (array $ themesInclude , array $ themesExclude )
131
137
{
132
- if ($ themesInclude [0 ] != 'all ' && $ themesExclude [0 ] != 'none ' ) {
133
- throw new \ InvalidArgumentException (
138
+ if ($ themesInclude [0 ] !== 'all ' && $ themesExclude [0 ] != = 'none ' ) {
139
+ throw new InvalidArgumentException (
134
140
'--theme (-t) and --exclude-theme cannot be used at the same time '
135
141
);
136
142
}
@@ -142,21 +148,21 @@ private function checkThemesInput(array $themesInclude, array $themesExclude)
142
148
* @param array $languagesInclude
143
149
* @param array $languagesExclude
144
150
* @return void
145
- * @throws \ InvalidArgumentException
151
+ * @throws InvalidArgumentException
146
152
*/
147
153
private function checkLanguagesInput (array $ languagesInclude , array $ languagesExclude )
148
154
{
149
- if ($ languagesInclude [0 ] != 'all ' ) {
155
+ if ($ languagesInclude [0 ] !== 'all ' ) {
150
156
foreach ($ languagesInclude as $ lang ) {
151
157
if (!$ this ->localeValidator ->isValid ($ lang )) {
152
- throw new \ InvalidArgumentException (
158
+ throw new InvalidArgumentException (
153
159
$ lang .
154
160
' argument has invalid value, please run info:language:list for list of available locales '
155
161
);
156
162
}
157
163
}
158
- if ($ languagesExclude [0 ] != 'none ' ) {
159
- throw new \ InvalidArgumentException (
164
+ if ($ languagesExclude [0 ] !== 'none ' ) {
165
+ throw new InvalidArgumentException (
160
166
'--language (-l) and --exclude-language cannot be used at the same time '
161
167
);
162
168
}
@@ -167,7 +173,7 @@ private function checkLanguagesInput(array $languagesInclude, array $languagesEx
167
173
* Version input checks
168
174
*
169
175
* @param string $contentVersion
170
- * @throws \ InvalidArgumentException
176
+ * @throws InvalidArgumentException
171
177
*/
172
178
private function checkVersionInput (string $ contentVersion ): void
173
179
{
@@ -179,12 +185,32 @@ private function checkVersionInput(string $contentVersion): void
179
185
);
180
186
181
187
if (!$ versionValidator ->isValid ($ contentVersion )) {
182
- throw new \ InvalidArgumentException (
188
+ throw new InvalidArgumentException (
183
189
'Argument " ' .
184
190
Options::CONTENT_VERSION
185
191
. '" has invalid value, content version should contain only characters, digits and dots '
186
192
);
187
193
}
188
194
}
189
195
}
196
+
197
+ /**
198
+ * Validate if --no-parent flag could be used with selected strategy
199
+ *
200
+ * @param bool $noParent
201
+ * @param string $strategy
202
+ * @throws InvalidArgumentException
203
+ */
204
+ private function checkNoParentInput (bool $ noParent , string $ strategy ): void
205
+ {
206
+ $ supportedStrategies = [
207
+ 'quick ' => true ,
208
+ ];
209
+
210
+ if ($ noParent && !array_key_exists ($ strategy , $ supportedStrategies )) {
211
+ throw new InvalidArgumentException (
212
+ sprintf ('Argument "%s" is not supported with "%s" strategy ' , Options::NO_PARENT , $ strategy )
213
+ );
214
+ }
215
+ }
190
216
}
0 commit comments