Merge pull request #496 from mpociot/replace-env-with-config

Replace `env` section with `config`
This commit is contained in:
Shalvah
2019-04-22 21:55:07 +01:00
committed by GitHub
2 changed files with 28 additions and 8 deletions

View File

@@ -103,7 +103,7 @@ return [
/*
* If no @response or @transformer declarations are found for the route,
* we'll try to get a sample response by attempting an API call.
* Configure the settings for the API call here,
* Configure the settings for the API call here.
*/
'response_calls' => [
/*
@@ -122,14 +122,15 @@ return [
],
/*
* Environment variables which should be set for the API call.
* Laravel config variables which should be set for the API call.
* This is a good place to ensure that notifications, emails
* and other external services are not triggered during the documentation API calls
* and other external services are not triggered
* during the documentation API calls
*/
'env' => [
'APP_ENV' => 'documentation',
'APP_DEBUG' => false,
// 'env_var' => 'value',
'config' => [
'app.env' => 'documentation',
'app.debug' => false,
// 'service.key' => 'value',
],
/*

View File

@@ -52,6 +52,7 @@ class ResponseCallStrategy
{
$this->startDbTransaction();
$this->setEnvironmentVariables($rulesToApply['env'] ?? []);
$this->setLaravelConfigs($rulesToApply['config'] ?? []);
}
/**
@@ -103,9 +104,11 @@ class ResponseCallStrategy
}
/**
* @param array $env
* @param array $config
*
* @return void
*
* @deprecated in favour of Laravel config variables
*/
private function setEnvironmentVariables(array $env)
{
@@ -117,6 +120,22 @@ class ResponseCallStrategy
}
}
/**
* @param array $config
*
* @return void
*/
private function setLaravelConfigs(array $config)
{
if (empty($config)) {
return;
}
foreach ($config as $name => $value) {
config([$name => $value]);
}
}
/**
* @return void
*/