1
- /**
1
+ /*
2
2
* Copyright © Magento, Inc. All rights reserved.
3
3
* See COPYING.txt for license details.
4
4
*/
5
+
5
6
package com .magento .idea .magento2plugin .project .validator ;
6
7
7
8
import com .intellij .openapi .options .ConfigurationException ;
8
- import com .magento .idea .magento2plugin .util .magento .MagentoVersionUtil ;
9
9
import com .magento .idea .magento2plugin .bundles .ValidatorBundle ;
10
10
import com .magento .idea .magento2plugin .project .SettingsForm ;
11
11
import com .magento .idea .magento2plugin .util .RegExUtil ;
12
12
import com .magento .idea .magento2plugin .util .magento .MagentoBasePathUtil ;
13
+ import com .magento .idea .magento2plugin .util .magento .MagentoVersionUtil ;
13
14
14
15
public class SettingsFormValidator {
15
- private static SettingsFormValidator INSTANCE = null ;
16
- private SettingsForm form ;
17
- private ValidatorBundle validatorBundle ;
18
-
19
- public static SettingsFormValidator getInstance (SettingsForm form ) {
20
- if (null == INSTANCE ) {
21
- INSTANCE = new SettingsFormValidator ();
22
- }
23
- INSTANCE .form = form ;
24
- return INSTANCE ;
25
- }
16
+ private final SettingsForm form ;
17
+ private final ValidatorBundle validatorBundle ;
26
18
27
- public SettingsFormValidator () {
19
+ public SettingsFormValidator (
20
+ final SettingsForm form
21
+ ) {
22
+ this .form = form ;
28
23
this .validatorBundle = new ValidatorBundle ();
29
24
}
30
25
26
+ /**
27
+ * Validate form.
28
+ *
29
+ * @throws ConfigurationException
30
+ */
31
31
public void validate () throws ConfigurationException {
32
32
if (!form .getSettings ().pluginEnabled ) {
33
33
return ;
34
34
}
35
35
36
36
if (!MagentoBasePathUtil .isMagentoFolderValid (form .getMagentoPath ())) {
37
- throw new ConfigurationException (validatorBundle .message ("validator.package.validPath" ));
37
+ throw new ConfigurationException (
38
+ validatorBundle .message ("validator.package.validPath" )
39
+ );
38
40
}
39
41
40
- String magentoVersion = form .getMagentoVersion ();
42
+ final String magentoVersion = form .getMagentoVersion ();
41
43
if (magentoVersion .length () == 0 ) {
42
- throw new ConfigurationException (validatorBundle .message ("validator.notEmpty" , "Magento Version" ));
44
+ throw new ConfigurationException (
45
+ validatorBundle .message ("validator.notEmpty" , "Magento Version" )
46
+ );
43
47
}
44
48
45
- if (!magentoVersion .matches (RegExUtil .MAGENTO_VERSION ) && !magentoVersion .equals (MagentoVersionUtil .DEFAULT_VERSION )) {
46
- throw new ConfigurationException (validatorBundle .message ("validator.magentoVersionInvalid" ));
49
+ if (!magentoVersion .matches (RegExUtil .MAGENTO_VERSION ) &&
50
+ !magentoVersion .equals (MagentoVersionUtil .DEFAULT_VERSION )) {
51
+ throw new ConfigurationException (
52
+ validatorBundle .message ("validator.magentoVersionInvalid" )
53
+ );
47
54
}
48
55
}
49
56
}
0 commit comments