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 {
87
87
public static final String CLASS_ELEMENT =
88
88
"\\ \\ ?" + PhpRegex .FQN + "(" + CLASS_MEMBER_NAME + ")?.*" ;
89
89
}
90
+
91
+ public static class CustomTheme {
92
+ public static final String MODULE_NAME = "app\\ /design\\ /(adminhtml|frontend)\\ /\\ w*\\ /\\ w*\\ /\\ w*" ;
93
+ }
90
94
}
Original file line number Diff line number Diff line change 15
15
import com .magento .idea .magento2plugin .magento .files .RegistrationPhp ;
16
16
import com .magento .idea .magento2plugin .util .RegExUtil ;
17
17
import org .jetbrains .annotations .Nullable ;
18
+ import java .util .regex .Matcher ;
19
+ import java .util .regex .Pattern ;
18
20
19
21
public final class GetModuleNameByDirectoryUtil {
20
- public static final int THEME_SPLIT_COUNT = 1 ;
21
- public static final String THEME_DIRECTORY_REGEX = "app\\ /design\\ /(adminhtml|frontend)\\ /" ;
22
22
23
23
private GetModuleNameByDirectoryUtil () {}
24
24
@@ -34,10 +34,14 @@ public static String execute(
34
34
final Project project
35
35
) {
36
36
// 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
+ }
41
45
}
42
46
43
47
final PhpFile registrationPhp = getRegistrationPhpRecursively (
You can’t perform that action at this time.
0 commit comments