Perhaps this article will help you: 
http://avalanche123.com/post/1215273326/symfony2-controller-testing

On Dec 7, 1:44 pm, "benjamin.dulau" <[email protected]> wrote:
> Hi,
>
> Where can i find an example for setter injection in Symfony 2 please ?
>
> I'm trying to do something like :
>
> use Application\HelloBundle\Service;
>
> class HelloController extends Controller
> {
>     /**
>      * @var ITestService
>      */
>     private $testService;
>
>     public function indexAction($name)
>     {
>         $test = $this->testService->say('Hey give me my service
> instance !!');
>         return $this->render('HelloBundle:Hello:index.twig',
> array('name' => $name, 'test' => $test));
>     }
>
>     public function setTestService(ITestService $testService)
>     {
>         $this->testService = $testService;
>         return $this;
>     }
>
> }
>
> But i'm missing something, what should be the configuration for that ?
>
> <services>
>     <service id="hello_controller" class="Application\HelloBundle
> \Controller\HelloController">
>         <call method="setTestService">
>             <argument type="service" id="service.test" />
>         </call>
>     </service>
>     <service id="service.test" class="Application\HelloBundle\Service
> \Impl\TestService" />
> </services>
>
> Thanks.
>
> br,
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to