8000 [DI] Fix cannot bind env var by ogizanagi · Pull Request #24850 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DI] Fix cannot bind env var #24850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected function processValue($value, $isRoot = false)
return $this->resolveArrays || !$v || !is_array($v) ? $v : $value;
}
if ($value instanceof Definition) {
$value->setBindings($this->processValue($value->getBindings()));
$changes = $value->getChanges();
if (isset($changes['class'])) {
$value->setClass($this->bag->resolveValue($value->getClass()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public function testAliasParametersShouldBeResolved()
$this->assertSame('foo', $this->container->getAlias('bar')->__toString());
}

public function testBindingsShouldBeResolved()
{
list($boundValue) = $this->container->getDefinition('foo')->getBindings()['$baz']->getValues();

$this->assertSame($this->container->getParameterBag()->resolveValue('%env(BAZ)%'), $boundValue);
}

private function createContainerBuilder()
{
$containerBuilder = new ContainerBuilder();
Expand All @@ -84,6 +91,7 @@ private function createContainerBuilder()
$fooDefinition->addMethodCall('%foo.method%', array('%foo.arg1%', '%foo.arg2%'));
$fooDefinition->setProperty('%foo.property.name%', '%foo.property.value%');
$fooDefinition->setFile('%foo.file%');
$fooDefinition->setBindings(array('$baz' => '%env(BAZ)%'));

$containerBuilder->setAlias('%alias.id%', 'foo');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __construct()

$this->services = array();
$this->methodMap = array(
'bar' => 'getBarService',
'test' => 'getTestService',
);

Expand Down Expand Up @@ -60,6 +61,16 @@ public function isFrozen()
return true;
}

/**
* Gets the public 'bar' shared service.
*
* @return \Symfony\Component\DependencyInjection\Tests\Fixtures\Bar
*/
protected function getBarService()
{
return $this->services['bar'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\Bar($this->getEnv('QUZ'));
}

/**
* Gets the public 'test' shared service.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ services:
- '%env(Bar)%'
- 'foo%bar%baz'
- '%baz%'
bar:
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Bar
public: true
bind:
$quz: '%env(QUZ)%'
0