diff --git a/Generator/RepositoryInjectionGenerator.php b/Generator/RepositoryInjectionGenerator.php index c4d941d..2f70606 100644 --- a/Generator/RepositoryInjectionGenerator.php +++ b/Generator/RepositoryInjectionGenerator.php @@ -87,13 +87,9 @@ public function generate(\ReflectionClass $original, PhpClass $proxy) ->indent() ->writeln('$processed[] = $this->container->get((string) $arg, $arg->getInvalidBehavior());') ->outdent() - ->writeln('} else if ($arg instanceof \Symfony\Component\DependencyInjection\Parameter) {') - ->indent() - ->writeln('$processed[] = $this->container->getParameter((string) $arg);') - ->outdent() ->writeln('} else {') ->indent() - ->writeln('$processed[] = $arg;') + ->writeln('$processed[] = $this->container->getParameterBag()->resolveValue((string) $arg);') ->outdent() ->writeln('}') ->outdent() diff --git a/Tests/Functional/Entities/TestEntity.php b/Tests/Functional/Entities/TestEntity.php new file mode 100644 index 0000000..a78c7c1 --- /dev/null +++ b/Tests/Functional/Entities/TestEntity.php @@ -0,0 +1,17 @@ +service; + } + + public function getParameter() + { + return $this->parameter; + } + + /** + * @DI\InjectParams({ + * "service" = @DI\Inject("some_service") + * }) + */ + public function setService($service) + { + $this->service = $service; + } + + /** + * @DI\InjectParams({ + * "parameter" = @DI\Inject("foo_%some_parameter%") + * }) + */ + public function setParameter($parameter) + { + $this->parameter = $parameter; + } +} diff --git a/Tests/Functional/Issue219Test.php b/Tests/Functional/Issue219Test.php new file mode 100644 index 0000000..d84fcb1 --- /dev/null +++ b/Tests/Functional/Issue219Test.php @@ -0,0 +1,18 @@ + false, 'config' => 'issue-219.yml')); + $kernel->boot(); + + $manager = $kernel->getContainer()->get('doctrine.orm.default_entity_manager'); + $repository = $manager->getRepository('\JMS\DiExtraBundle\Tests\Functional\Entities\TestEntity'); + + $this->assertSame($kernel->getContainer()->get('some_service'), $repository->getService()); + $this->assertEquals("foo_42", $repository->getParameter()); + } +} diff --git a/Tests/Functional/config/issue-219.yml b/Tests/Functional/config/issue-219.yml new file mode 100644 index 0000000..218f460 --- /dev/null +++ b/Tests/Functional/config/issue-219.yml @@ -0,0 +1,17 @@ +imports: + - { resource: doctrine.yml } + +doctrine: + orm: + mappings: + test_entities: + type: annotation + dir: %kernel.root_dir%/Entities + prefix: JMS\DiExtraBundle\Tests\Functional\Entities + +services: + some_service: + class: stdClass + +parameters: + some_parameter: 42