@@ -28,6 +28,11 @@ abstract class AbstractConfig extends Data
28
28
*/
29
29
protected $ filecheck = true ;
30
30
31
+ /**
32
+ * @var string
33
+ */
34
+ private $ currentBasepath ;
35
+
31
36
/**
32
37
* @var array
33
38
*/
@@ -72,6 +77,8 @@ public function addConfig($name, $file)
72
77
*/
73
78
public function readConfig ($ file )
74
79
{
80
+ $ this ->currentBasepath = dirname ($ file );
81
+
75
82
$ config = $ this ->readFile ($ file );
76
83
$ config = $ this ->extractImports ($ config );
77
84
$ config = $ this ->extractDefault ($ config );
@@ -127,9 +134,11 @@ private function extractImports(array $config)
127
134
$ this ->imports = [];
128
135
foreach ($ config ['imports ' ] as $ key => $ import ) {
129
136
if (false === empty ($ import ['resource ' ])) {
137
+ $ include = $ this ->checkPath ($ import ['resource ' ]);
138
+
130
139
$ this ->imports = array_replace_recursive (
131
140
$ this ->imports ,
132
- $ this ->readFile ($ import [ ' resource ' ] )
141
+ $ this ->readFile ($ include )
133
142
);
134
143
}
135
144
}
@@ -163,4 +172,19 @@ private function mergeDefault()
163
172
{
164
173
$ this ->default = array_replace_recursive ($ this ->imports , $ this ->default );
165
174
}
175
+
176
+ /**
177
+ * Only add basepath if not already in filename.
178
+ *
179
+ * @param string $include
180
+ * @return string
181
+ */
182
+ private function checkPath ($ include )
183
+ {
184
+ if (0 !== strpos ($ include , $ this ->currentBasepath )) {
185
+ $ include = $ this ->currentBasepath . '/ ' . $ include ;
186
+ }
187
+
188
+ return $ include ;
189
+ }
166
190
}
0 commit comments