Skip to content

Commit c67fc7a

Browse files
author
Vitaliy
authored
Merge pull request #435 from drpayyne/issue-433
Fixed NPTR exception in theme directory view model action
2 parents d8cea9c + c5ea1db commit c67fc7a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/com/magento/idea/magento2plugin/util/magento/GetModuleNameByDirectoryUtil.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
public final class GetModuleNameByDirectoryUtil {
2020

21+
public static final int THEME_SPLIT_COUNT = 1;
22+
public static final String THEME_DIRECTORY_REGEX = "app\\/design\\/(adminhtml|frontend)\\/";
23+
2124
private GetModuleNameByDirectoryUtil() {}
2225

2326
/**
@@ -31,6 +34,13 @@ public static String execute(
3134
final PsiDirectory psiDirectory,
3235
final Project project
3336
) {
37+
// Check if directory is theme directory and return module name from directory path if yes
38+
final String[] splits = psiDirectory.getVirtualFile().getPath()
39+
.split(THEME_DIRECTORY_REGEX);
40+
if (splits.length > THEME_SPLIT_COUNT) {
41+
return splits[1].split("\\/")[2];
42+
}
43+
3444
final PhpFile registrationPhp = getRegistrationPhpRecursively(
3545
psiDirectory,
3646
project

0 commit comments

Comments
 (0)