Skip to content

Ability to inject a parameter into an EntityRepository without an extra service - #182

Open
juadielon wants to merge 1 commit into
schmittjoh:masterfrom
juadielon:master
Open

Ability to inject a parameter into an EntityRepository without an extra service#182
juadielon wants to merge 1 commit into
schmittjoh:masterfrom
juadielon:master

Conversation

@juadielon

Copy link
Copy Markdown

This allows to inject parameters into an EntityRepository without a service by doing:

// src/Acme/MyBundle/Repository/MyRepository.php

<?php

namespace Acme\MyBundle\Repository;

use JMS\DiExtraBundle\Annotation as DI;
use Doctrine\ORM\EntityRepository;

class MyRepository extends EntityRepository
{
    private $myVar;

    /**
     * @DI\InjectParams({
     *     "myVar" = @DI\Inject("%my.parameter%")
     * })
     */
    public function setMyVar($myVar)
    {
        $this->myVar = $myVar;
    }
// ...
}

// And in the app/config/config.yml

parameters:
    my.parameter = any_value

@schmittjoh

Copy link
Copy Markdown
Owner

I don't think this should be necessary. We have logic for injecting parameters in the AnnotationDriver already.

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 this pull request may close these issues.

2 participants