File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
src/com/magento/idea/magento2plugin/util Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -87,4 +87,8 @@ public static class XmlRegex {
8787 public static final String CLASS_ELEMENT =
8888 "\\ \\ ?" + PhpRegex .FQN + "(" + CLASS_MEMBER_NAME + ")?.*" ;
8989 }
90+
91+ public static class CustomTheme {
92+ public static final String MODULE_NAME = "app\\ /design\\ /(adminhtml|frontend)\\ /\\ w*\\ /\\ w*\\ /\\ w*" ;
93+ }
9094}
Original file line number Diff line number Diff line change 1515import com .magento .idea .magento2plugin .magento .files .RegistrationPhp ;
1616import com .magento .idea .magento2plugin .util .RegExUtil ;
1717import org .jetbrains .annotations .Nullable ;
18+ import java .util .regex .Matcher ;
19+ import java .util .regex .Pattern ;
1820
1921public final class GetModuleNameByDirectoryUtil {
20- public static final int THEME_SPLIT_COUNT = 1 ;
21- public static final String THEME_DIRECTORY_REGEX = "app\\ /design\\ /(adminhtml|frontend)\\ /" ;
2222
2323 private GetModuleNameByDirectoryUtil () {}
2424
@@ -34,10 +34,14 @@ public static String execute(
3434 final Project project
3535 ) {
3636 // Check if directory is theme directory and return module name from directory path if yes
37- final String [] splits = psiDirectory .getVirtualFile ().getPath ()
38- .split (THEME_DIRECTORY_REGEX );
39- if (splits .length > THEME_SPLIT_COUNT ) {
40- return splits [1 ].split ("\\ /" )[2 ];
37+ final String path = psiDirectory .getVirtualFile ().getPath ();
38+ final Pattern pattern = Pattern .compile (RegExUtil .CustomTheme .MODULE_NAME );
39+ final Matcher matcher = pattern .matcher (path );
40+ while (matcher .find ()) {
41+ final String moduleNamePath = matcher .group (0 );
42+ if (!moduleNamePath .isEmpty ()) {
43+ return moduleNamePath .split ("/" )[5 ];
44+ }
4145 }
4246
4347 final PhpFile registrationPhp = getRegistrationPhpRecursively (
You can’t perform that action at this time.
0 commit comments