Skip to content
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

Parameter injection failing for doctrine repositories #219

Open
Adirelle opened this issue Nov 3, 2015 · 6 comments · May be fixed by #229
Open

Parameter injection failing for doctrine repositories #219

Adirelle opened this issue Nov 3, 2015 · 6 comments · May be fixed by #229

Comments

@Adirelle
Copy link

Adirelle commented Nov 3, 2015

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.

@hoshsadiq
Copy link

This repository is not a service, hence why it won't work.

@Adirelle
Copy link
Author

Adirelle commented Nov 9, 2015

@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.

@nibynool
Copy link

nibynool commented Nov 9, 2015

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.

@antoinemineau
Copy link

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 ?

@schmittjoh
Copy link
Owner

Is there a pull-request for this?

Adirelle added a commit to Adirelle/JMSDiExtraBundle that referenced this issue Dec 21, 2015
@Adirelle
Copy link
Author

@schmittjoh I've tried to create a functional test (see above) but I'm having issues to make it run on my Windows box.

Adirelle added a commit to Adirelle/JMSDiExtraBundle that referenced this issue Dec 22, 2015
Adirelle added a commit to Adirelle/JMSDiExtraBundle that referenced this issue Dec 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants