Skip to content

Commit

Permalink
Fixed default boolean values being overwritten in per-path configs (#186
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alexndlm authored Jun 24, 2024
1 parent fda78aa commit 3a526fe
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ public function getConfigTreeBuilder(): TreeBuilder
->children()
->arrayNode('defaults')
->addDefaultsIfNotSet()
->append($this->getAllowCredentials())
->append($this->getAllowCredentials(true))
->append($this->getAllowOrigin())
->append($this->getAllowHeaders())
->append($this->getAllowMethods())
->append($this->getAllowPrivateNetwork())
->append($this->getExposeHeaders())
->append($this->getMaxAge())
->append($this->getHosts())
->append($this->getOriginRegex())
->append($this->getOriginRegex(true))
->append($this->getForcedAllowOriginValue())
->append($this->getSkipSameAsOrigin())
->append($this->getSkipSameAsOrigin(true))
->end()

->arrayNode('paths')
Expand All @@ -75,18 +75,24 @@ public function getConfigTreeBuilder(): TreeBuilder
return $treeBuilder;
}

private function getSkipSameAsOrigin(): BooleanNodeDefinition
private function getSkipSameAsOrigin(bool $withDefaultValue = false): BooleanNodeDefinition
{
$node = new BooleanNodeDefinition('skip_same_as_origin');
$node->defaultTrue();

if ($withDefaultValue) {
$node->defaultTrue();
}

return $node;
}

private function getAllowCredentials(): BooleanNodeDefinition
private function getAllowCredentials(bool $withDefaultValue = false): BooleanNodeDefinition
{
$node = new BooleanNodeDefinition('allow_credentials');
$node->defaultFalse();

if ($withDefaultValue) {
$node->defaultFalse();
}

return $node;
}
Expand Down Expand Up @@ -192,10 +198,13 @@ private function getHosts(): ArrayNodeDefinition
return $node;
}

private function getOriginRegex(): BooleanNodeDefinition
private function getOriginRegex(bool $withDefaultValue = false): BooleanNodeDefinition
{
$node = new BooleanNodeDefinition('origin_regex');
$node->defaultFalse();

if ($withDefaultValue) {
$node->defaultFalse();
}

return $node;
}
Expand Down

0 comments on commit 3a526fe

Please sign in to comment.