@@ -28,6 +28,11 @@ abstract class AbstractConfig extends Data
2828 */
2929 protected $ filecheck = true ;
3030
31+ /**
32+ * @var string
33+ */
34+ private $ currentBasepath ;
35+
3136 /**
3237 * @var array
3338 */
@@ -72,6 +77,8 @@ public function addConfig($name, $file)
7277 */
7378 public function readConfig ($ file )
7479 {
80+ $ this ->currentBasepath = dirname ($ file );
81+
7582 $ config = $ this ->readFile ($ file );
7683 $ config = $ this ->extractImports ($ config );
7784 $ config = $ this ->extractDefault ($ config );
@@ -127,9 +134,11 @@ private function extractImports(array $config)
127134 $ this ->imports = [];
128135 foreach ($ config ['imports ' ] as $ key => $ import ) {
129136 if (false === empty ($ import ['resource ' ])) {
137+ $ include = $ this ->checkPath ($ import ['resource ' ]);
138+
130139 $ this ->imports = array_replace_recursive (
131140 $ this ->imports ,
132- $ this ->readFile ($ import [ ' resource ' ] )
141+ $ this ->readFile ($ include )
133142 );
134143 }
135144 }
@@ -163,4 +172,19 @@ private function mergeDefault()
163172 {
164173 $ this ->default = array_replace_recursive ($ this ->imports , $ this ->default );
165174 }
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+ }
166190}
0 commit comments