Skip to content

Commit 3a3e10a

Browse files
Only look for adapters in not empty values
1 parent 86a6d88 commit 3a3e10a

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/Configuration/Loader/File.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use phpbu\App\Util\Path as PathUtil;
99

1010
/**
11-
* Base class for file based phpbu configuration.
11+
* Base class for file based phpbu configuration
1212
*
1313
* @package phpbu
1414
* @subpackage App
@@ -21,28 +21,28 @@
2121
abstract class File
2222
{
2323
/**
24-
* Path to config file.
24+
* Path to config file
2525
*
2626
* @var string
2727
*/
2828
protected $filename;
2929

3030
/**
31-
* Path to config file.
31+
* Path to config file
3232
*
3333
* @var array
3434
*/
3535
protected $adapters;
3636

3737
/**
38-
* Handling the bootstrapping.
38+
* Handling the bootstrapping
3939
*
4040
* @var \phpbu\App\Configuration\Bootstrapper
4141
*/
4242
protected $bootstrapper;
4343

4444
/**
45-
* File constructor.
45+
* File constructor
4646
*
4747
* @param string $file
4848
* @param \phpbu\App\Configuration\Bootstrapper $bootstrapper
@@ -54,7 +54,7 @@ public function __construct(string $file, Configuration\Bootstrapper $bootstrapp
5454
}
5555

5656
/**
57-
* Returns the phpbu Configuration.
57+
* Returns the phpbu Configuration
5858
*
5959
* @param \phpbu\App\Factory $factory
6060
* @return \phpbu\App\Configuration
@@ -77,7 +77,7 @@ public function getConfiguration(AppFactory $factory)
7777
}
7878

7979
/**
80-
* Load all available config adapters.
80+
* Load all available config adapters
8181
*
8282
* @param \phpbu\App\Factory $factory
8383
* @throws \phpbu\App\Exception
@@ -90,7 +90,7 @@ protected function setupAdapters(AppFactory $factory)
9090
}
9191

9292
/**
93-
* Return a registered adapter.
93+
* Return a registered adapter
9494
*
9595
* @param string $name
9696
* @return \phpbu\App\Adapter
@@ -105,37 +105,37 @@ protected function getAdapter($name)
105105
}
106106

107107
/**
108-
* Return list of adapter configs.
108+
* Return list of adapter configs
109109
*
110110
* @return array
111111
*/
112112
abstract protected function getAdapterConfigs();
113113

114114
/**
115-
* Set the phpbu application settings.
115+
* Set the phpbu application settings
116116
*
117117
* @param \phpbu\App\Configuration $configuration
118118
*/
119119
abstract public function setAppSettings(Configuration $configuration);
120120

121121
/**
122-
* Set the log configuration.
122+
* Set the log configuration
123123
*
124124
* @param \phpbu\App\Configuration $configuration
125125
* @throws \phpbu\App\Exception
126126
*/
127127
abstract public function setLoggers(Configuration $configuration);
128128

129129
/**
130-
* Set the backup configurations.
130+
* Set the backup configurations
131131
*
132132
* @param \phpbu\App\Configuration $configuration
133133
* @throws \phpbu\App\Exception
134134
*/
135135
abstract public function setBackups(Configuration $configuration);
136136

137137
/**
138-
* Handles the bootstrap file inclusion.
138+
* Handles the bootstrap file inclusion
139139
*
140140
* @param \phpbu\App\Configuration $configuration
141141
* @throws \phpbu\App\Exception
@@ -146,7 +146,7 @@ protected function handleBootstrap(Configuration $configuration)
146146
}
147147

148148
/**
149-
* Converts a path to an absolute one if necessary.
149+
* Converts a path to an absolute one if necessary
150150
*
151151
* @param string $path
152152
* @param boolean $useIncludePath
@@ -158,7 +158,7 @@ protected function toAbsolutePath($path, $useIncludePath = false)
158158
}
159159

160160
/**
161-
* Return option value.
161+
* Return option value
162162
* Checks if the value should be fetched from an Adapter, if not it just returns the value.
163163
*
164164
* @param string $value
@@ -167,16 +167,18 @@ protected function toAbsolutePath($path, $useIncludePath = false)
167167
*/
168168
protected function getAdapterizedValue($value)
169169
{
170-
foreach (Util::getAdapterReplacements($value) as $replacement) {
171-
$search = $replacement['search'];
172-
$replace = $this->getAdapter($replacement['adapter'])->getValue($replacement['path']);
173-
$value = str_replace($search, $replace, $value);
170+
if (!empty($value)) {
171+
foreach (Util::getAdapterReplacements($value) as $replacement) {
172+
$search = $replacement['search'];
173+
$replace = $this->getAdapter($replacement['adapter'])->getValue($replacement['path']);
174+
$value = str_replace($search, $replace, $value);
175+
}
174176
}
175177
return $value;
176178
}
177179

178180
/**
179-
* Load the file.
181+
* Load the file
180182
*
181183
* @param string $filename
182184
* @throws \phpbu\App\Exception

0 commit comments

Comments
 (0)