Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
fix(command): Decode configuration one more time
Browse files Browse the repository at this point in the history
When env is used in symfony configuration it is resolved in runtime when using as default value for
option in command
  • Loading branch information
k911 committed Sep 30, 2018
1 parent a046b8b commit 32f9776
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/Bridge/Symfony/Bundle/Command/AbstractServerStartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ protected function prepareRuntimeConfiguration(HttpServerConfiguration $serverCo
{
$trustedHosts = $input->getOption('trusted-hosts');
$trustedProxies = $input->getOption('trusted-proxies');
$runtimeConfiguration['trustedHosts'] = \is_string($trustedHosts) ? decode_string_as_set($trustedHosts) : $trustedHosts;
$runtimeConfiguration['trustedProxies'] = \is_string($trustedProxies) ? decode_string_as_set($trustedProxies) : $trustedProxies;
$runtimeConfiguration['trustedHosts'] = $this->decodeSet($trustedHosts);
$runtimeConfiguration['trustedProxies'] = $this->decodeSet($trustedProxies);

Assertion::isArray($runtimeConfiguration['trustedProxies']);
if (\in_array('*', $runtimeConfiguration['trustedProxies'], true)) {
Expand All @@ -178,6 +178,28 @@ protected function prepareRuntimeConfiguration(HttpServerConfiguration $serverCo
return $runtimeConfiguration;
}

/**
* @param mixed $set
*
* @throws \Assert\AssertionFailedException
*
* @return array
*/
private function decodeSet($set): array
{
if (\is_string($set)) {
return decode_string_as_set($set);
}

Assertion::isArray($set);

if (1 === \count($set)) {
return decode_string_as_set($set[0]);
}

return $set;
}

/**
* Rows produced by this function will be printed on server startup in table with following form:
* | Configuration | Value |.
Expand Down

0 comments on commit 32f9776

Please sign in to comment.