16
16
import com .jetbrains .php .lang .psi .elements .impl .ClassConstImpl ;
17
17
import com .magento .idea .magento2plugin .magento .files .RegistrationPhp ;
18
18
import com .magento .idea .magento2plugin .magento .packages .ComponentType ;
19
+ import com .magento .idea .magento2plugin .magento .packages .Package ;
19
20
import java .util .Collection ;
20
21
import org .jetbrains .annotations .NotNull ;
22
+ import org .jetbrains .annotations .Nullable ;
21
23
22
24
public final class GetMagentoModuleUtil {
23
25
@@ -46,6 +48,9 @@ public static MagentoModuleData getByContext(
46
48
if (registrationFile == null ) {
47
49
return null ;
48
50
}
51
+ final PsiDirectory configDir = registrationFile
52
+ .getContainingDirectory ()
53
+ .findSubdirectory (Package .moduleBaseAreaDir );
49
54
final Collection <MethodReference > methodReferences = PsiTreeUtil .findChildrenOfType (
50
55
registrationFile ,
51
56
MethodReference .class
@@ -71,7 +76,7 @@ public static MagentoModuleData getByContext(
71
76
return null ;
72
77
}
73
78
74
- return new MagentoModuleData (name , resolvedType );
79
+ return new MagentoModuleData (name , resolvedType , configDir );
75
80
}
76
81
77
82
return null ;
@@ -124,13 +129,36 @@ public static class MagentoModuleData {
124
129
125
130
private final String name ;
126
131
private final ComponentType type ;
127
-
132
+ private final PsiDirectory configDir ;
133
+
134
+ /**
135
+ * Default constructor.
136
+ *
137
+ * @param name String
138
+ * @param type ComponentType
139
+ */
128
140
public MagentoModuleData (
129
141
final @ NotNull String name ,
130
142
final @ NotNull ComponentType type
143
+ ) {
144
+ this (name , type , null );
145
+ }
146
+
147
+ /**
148
+ * Constructor with a config directory specified.
149
+ *
150
+ * @param name String
151
+ * @param type ComponentType
152
+ * @param configDir PsiDirectory
153
+ */
154
+ public MagentoModuleData (
155
+ final @ NotNull String name ,
156
+ final @ NotNull ComponentType type ,
157
+ final @ Nullable PsiDirectory configDir
131
158
) {
132
159
this .name = name ;
133
160
this .type = type ;
161
+ this .configDir = configDir ;
134
162
}
135
163
136
164
public String getName () {
@@ -140,5 +168,9 @@ public String getName() {
140
168
public ComponentType getType () {
141
169
return type ;
142
170
}
171
+
172
+ public @ Nullable PsiDirectory getConfigDir () {
173
+ return configDir ;
174
+ }
143
175
}
144
176
}
0 commit comments