Skip to content

Commit

Permalink
Merge pull request laravel#269 from phanan/feature-1
Browse files Browse the repository at this point in the history
[5.1] Allow getting path to configuration directory
  • Loading branch information
taylorotwell committed Oct 19, 2015
2 parents 3855466 + 8800a2e commit 3079aab
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,19 +844,30 @@ public function configure($name)
}

/**
* Get the path to the given configuration file.
* Get the path to the given configuration file, or to the directory if the argument is
* empty.
*
* @param string $name
* @return string
*/
protected function getConfigurationPath($name)
public function getConfigurationPath($name = null)
{
$appConfigPath = ($this->configPath ?: $this->basePath('config')).'/'.$name.'.php';
if (! $name) {
$appConfigDir = ($this->configPath ?: $this->basePath('config')).'/';

if (file_exists($appConfigPath)) {
return $appConfigPath;
} elseif (file_exists($path = __DIR__.'/../config/'.$name.'.php')) {
return $path;
if (file_exists($appConfigDir)) {
return $appConfigDir;
} elseif (file_exists($path = __DIR__.'/../config/')) {
return $path;
}
} else {
$appConfigPath = ($this->configPath ?: $this->basePath('config')).'/'.$name.'.php';

if (file_exists($appConfigPath)) {
return $appConfigPath;
} elseif (file_exists($path = __DIR__.'/../config/'.$name.'.php')) {
return $path;
}
}
}

Expand Down

0 comments on commit 3079aab

Please sign in to comment.