diff --git a/src/ContainerBasedContainerAccessor.php b/src/ContainerBasedContainerAccessor.php index be6956f..84a4fea 100644 --- a/src/ContainerBasedContainerAccessor.php +++ b/src/ContainerBasedContainerAccessor.php @@ -41,13 +41,17 @@ public function getService($id) */ public function getParameters() { + $parameterBag = $this->container->getParameterBag(); if (!$this->container->isFrozen()) { - $parameterBag = clone $this->container->getParameterBag(); + $parameterBag = clone $parameterBag; $parameterBag->resolve(); - return $parameterBag->all(); + // Values are automatically unescaped during resolving, need to revert it + $parameterBag->add(array_map(function ($unescapedValue) use ($parameterBag) { + return $parameterBag->escapeValue($unescapedValue); + }, $parameterBag->all())); } - return $this->container->getParameterBag()->all(); + return $parameterBag->all(); } } diff --git a/tests/CrossContainerProcessorTest.php b/tests/CrossContainerProcessorTest.php index ab9bedf..f04bb5d 100644 --- a/tests/CrossContainerProcessorTest.php +++ b/tests/CrossContainerProcessorTest.php @@ -147,6 +147,22 @@ public function it_resolves_cross_container_parameters_in_service_definition_arr static::assertSame(['parameter' => '42'], $baseContainer->get('array_object')->getArrayCopy()); } + /** + * @test + */ + public function it_resolves_cross_container_escaped_parameters() + { + $externalContainer = new ContainerBuilder(); + $externalContainer->setParameter('parameter', '%%s?%%s'); + + $baseContainer = new ContainerBuilder(); + $baseContainer->setParameter('parameter', '%__external__.parameter%'); + + $this->buildContainerWithDependencies($baseContainer, ['external' => $externalContainer]); + + static::assertSame('%s?%s', $baseContainer->getParameter('parameter')); + } + /** * @param ContainerBuilder $baseContainer * @param ContainerBuilder[] $externalContainers