diff --git a/Generator/RepositoryInjectionGenerator.php b/Generator/RepositoryInjectionGenerator.php index c4d941d..dd35694 100755 --- a/Generator/RepositoryInjectionGenerator.php +++ b/Generator/RepositoryInjectionGenerator.php @@ -91,6 +91,10 @@ public function generate(\ReflectionClass $original, PhpClass $proxy) ->indent() ->writeln('$processed[] = $this->container->getParameter((string) $arg);') ->outdent() + ->writeln('} elseif(0 === strpos($arg, \'%\')) {') + ->indent() + ->writeln('$processed[] = $this->container->getParameter(substr((string)$arg, 1, -1));') + ->outdent() ->writeln('} else {') ->indent() ->writeln('$processed[] = $arg;') diff --git a/Tests/Functional/Bundle/TestBundle/Entity/User.php b/Tests/Functional/Bundle/TestBundle/Entity/User.php new file mode 100644 index 0000000..412b92f --- /dev/null +++ b/Tests/Functional/Bundle/TestBundle/Entity/User.php @@ -0,0 +1,22 @@ + + */ +class UserRepository extends EntityRepository +{ + protected $param; + protected $em; + + /** + * @DI\InjectParams({ + * "param" = @DI\Inject("%some.parameter%"), + * "em" = @DI\Inject("doctrine.orm.default_entity_manager") + * }) + */ + public function setParam($param, $em) + { + $this->param = $param; + $this->em = $em; + } +} diff --git a/Tests/Functional/InjectParamsRepositoryTest.php b/Tests/Functional/InjectParamsRepositoryTest.php new file mode 100644 index 0000000..dbfe786 --- /dev/null +++ b/Tests/Functional/InjectParamsRepositoryTest.php @@ -0,0 +1,20 @@ + true, 'config' => 'doctrine.yml')); + $kernel->boot(); + + + $em = $kernel->getContainer()->get('doctrine.orm.default_entity_manager'); + $repo = $em->getRepository('JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Entity\User'); + + $this->assertAttributeEquals($em, 'em', $repo); + $this->assertAttributeEquals($kernel->getContainer()->getParameter('some.parameter'), 'param', $repo); + } +} \ No newline at end of file diff --git a/Tests/Functional/config/default.yml b/Tests/Functional/config/default.yml index c04fc33..0108252 100644 --- a/Tests/Functional/config/default.yml +++ b/Tests/Functional/config/default.yml @@ -13,3 +13,6 @@ services: controller.hello: class: JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller\ServiceController arguments: [ "@router" ] + +parameters: + some.parameter: [some_array] \ No newline at end of file