File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
src/com/magento/idea/magento2plugin Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 11validator.notEmpty =The {0} field must not be empty
22validator.box.notEmpty =The {0} field must contain a valid selection from the dropdown
33validator.package.validPath =Please specify a valid Magento 2 installation path
4+ validator.package.validPathComposerFiles =File composer.json is missing in the current Magento 2 installation path
5+ validator.package.validPathVendor =Vendor dir is corrupt or missing in the current Magento 2 installation path
46validator.properties.notEmpty =The properties must not be empty
57validator.alphaNumericCharacters =The {0} field must contain letters and numbers only
68validator.alphaNumericAndUnderscoreCharacters ={0} must contain letters, numbers and underscores only
Original file line number Diff line number Diff line change @@ -28,14 +28,30 @@ public SettingsFormValidator(
2828 *
2929 * @throws ConfigurationException Exception
3030 */
31+ @ SuppressWarnings ({"PMD.CyclomaticComplexity" , "PMD.AvoidDeeplyNestedIfStmts" })
3132 public void validate () throws ConfigurationException {
3233 if (form .isBeingUsed ()) {
33- if (!MagentoBasePathUtil .isMagentoFolderValid (form .getMagentoPath ())) {
34+ final String magentoRootPath = form .getMagentoPath ();
35+ final boolean isMagentoFrameworkDirExist =
36+ MagentoBasePathUtil .isMagentoFolderValid (magentoRootPath );
37+
38+ if (!MagentoBasePathUtil .isComposerJsonExists (magentoRootPath )) {
39+ if (isMagentoFrameworkDirExist ) {
40+ throw new ConfigurationException (
41+ validatorBundle .message ("validator.package.validPathComposerFiles" )
42+ );
43+ }
3444 throw new ConfigurationException (
3545 validatorBundle .message ("validator.package.validPath" )
3646 );
3747 }
3848
49+ if (!isMagentoFrameworkDirExist ) {
50+ throw new ConfigurationException (
51+ validatorBundle .message ("validator.package.validPathVendor" )
52+ );
53+ }
54+
3955 final String magentoVersion = form .getMagentoVersion ();
4056 if (magentoVersion .length () == 0 ) {
4157 throw new ConfigurationException (
Original file line number Diff line number Diff line change 99import com .intellij .openapi .vfs .LocalFileSystem ;
1010import com .intellij .openapi .vfs .VfsUtil ;
1111import com .intellij .openapi .vfs .VirtualFile ;
12+ import com .magento .idea .magento2plugin .magento .files .ComposerJson ;
1213import com .magento .idea .magento2plugin .magento .packages .Package ;
1314import java .util .Arrays ;
1415import org .jetbrains .annotations .NotNull ;
@@ -18,7 +19,7 @@ public final class MagentoBasePathUtil {
1819 private MagentoBasePathUtil () {}
1920
2021 /**
21- * Method detects Magento Framework Root.
22+ * Method detects Magento Framework Root (check if magento framework exists) .
2223 *
2324 * @param path String
2425 * @return boolean
@@ -42,6 +43,25 @@ public static boolean isMagentoFolderValid(final String path) {
4243 return false ;
4344 }
4445
46+ /**
47+ * Check if composer.json exists in directory.
48+ *
49+ * @param path String
50+ * @return boolean
51+ */
52+ public static Boolean isComposerJsonExists (final String path ) {
53+ if (StringUtil .isEmptyOrSpaces (path )) {
54+ return false ;
55+ }
56+ final VirtualFile magentoRoot = LocalFileSystem .getInstance ().findFileByPath (path );
57+
58+ if (magentoRoot == null || !magentoRoot .isDirectory ()) {
59+ return false ;
60+ }
61+
62+ return magentoRoot .findChild (ComposerJson .FILE_NAME ) != null ;
63+ }
64+
4565 /**
4666 * Check if specified path belongs to the correct vendor name.
4767 *
You can’t perform that action at this time.
0 commit comments