Hi,

I'm trying desperately to use setter injection within a bundle.

I have a bundle named "NewsBundle" under src/Bundle/NewsBundle.

The NewsBundle adds an Extension to container like (simplified version) :

    public function configLoad($config, ContainerBuilder $container)
    {
        $loader = new XmlFileLoader($container, 
__DIR__.'/../Resources/config');
        $loader->load('domain.xml');
        $loader->load('controller.xml');    
    }
  
    // .....
    
    public function getAlias()
    {
        return 'news';
    }

I have a controller at => Bundle/NewsBundle/Controller/NewsController and 
i'm trying to inject a repository into it, by setter.

    public function setNewsRepository(NewsRepositoryInterface 
$newsRepository)
    {
        $this->newsRepository = $newsRepository;
    }


In order to do that, i have into => 
Bundle/NewsBundle/Resources/config/controller.xml :

<service id="news.controller.news" 
class="Bundle\NewsBundle\Controller\NewsController"> 
    <call method="setNewsRepository"> 
        <argument type="service" id="news.domain.repository.news" />
    </call> 
</service>

And into => Bundle/NewsBundle/Resources/config/domain.xml :

<service id="news.domain.repository.news" 
class="Bundle\NewsBundle\NewsBundle" factory-method="getRepository" 
shared="true">
    <argument type="service" id="news.entity_manager" />
    <argument type="string">Bundle\NewsBundle\Domain\Entity\News</argument>
</service>

(don't pay attention to the repository config :p)


The thing is, the setter is never called, so i wonder what is the convention 
for controller service id ? dots ? underscores ?
You can imagine, i tried a few combinations (news_controller_news, 
news_controller, etc.), but no way, i just can't figure out how to do it ! 
:)

Any idea please ?

Thanks,
Benjamin.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to