JMSDiExtraBundle
JMSDiExtraBundle copied to clipboard
Parameter injection failing for doctrine repositories
It seems there is an issue with version 1.6.0.
The following snippet fails to inject the actual value of the parameter, instead, it injects the string %my_parameter%
.
use JMS\DiExtraBundle\Annotation as DI;
class MyEntityRepository extends EntityRepository
{
private $var;
/**
* @param float $var
* @DI\InjectParams({"var" = @DI\Inject("%my_parameter%")})
*/
public function setVar($var)
{
$this->var = $var;
}
}
It seems this case is not covered by the tests.
This repository is not a service, hence why it won't work.
@hoshsadiq I think you overlooked the documentation and what I've said:
- With the Doctrine integration enabled (which is the case by default), JMSDiExtraBundle can inject into Doctrine repositories (it decorates the entity manager to do so).
- In my case, JMSDiExtraBundle actually injects something, which verifies the previous point, but not the right thing, i.e. it injects
%my_parameter%
instead of the actual value of my_parameter.
I can confirm this in my situation as well. The property is populated with the provided parameter string instead of the value of the parameter.
Same issue here.
It injects the parameter %my_parameter% and not the actual value. There is a stackoverflow question with an answer saying that you can use this bundle to inject a parameter in a repository : http://stackoverflow.com/a/23297355/3726645
I guess this worked at some point, but not anymore ?
Is there a pull-request for this?
@schmittjoh I've tried to create a functional test (see above) but I'm having issues to make it run on my Windows box.