Skip to content
This repository was archived by the owner on Oct 26, 2024. It is now read-only.

Commit 7c3a27d

Browse files
committed
Merge pull request #5 from maschmann/maschmann-patch-1
Fixed directory for includes
2 parents 63b3747 + 5511229 commit 7c3a27d

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

Config/AbstractConfig.php

+25-1
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)