Hi.. I'm trying to implement DDD patterns using interfaces..
I have interfaces to repositories and Services
this is my code to a service :


> public function __construct(PaqueteRepositoryInterface $paqueteRepository,
>         SubtipoRepositoryInterface $subtipoRepository)
>     {
>         if ($paqueteRepository == null) {
>             throw new NullArgumentException('El valor del argumento fue
> null. El argumento fue: $paqueteRepository' );
>         }
>         if ($subtipoRepository == null) {
>             throw new NullArgumentException('El valor del argumento fue
> null. El argumento fue: $subtipoRepository' );
>         }
> 
>         $this->paqueteRepository = $paqueteRepository;
>         $this->subtipoRepository = $subtipoRepository;
>     }

and I inject from 

> return array(
>     'invokables' => array(        
>         'agencia_paquete_mapper' =>
> 'Agencia\Infrastructure\Mapper\PaqueteRepository',
>         'agencia_subtipo_mapper' =>
> 'Agencia\Infrastructure\Mapper\SubtipoRepository',
>     ),
>     'factories' => array(
>         'agencia_paquete_service' => function ($sm) {
>             return new Application\Service\PaqueteService(
>                 $sm->get('agencia_paquete_mapper'),
>                 $sm->get('agencia_subtipo_mapper')
>             );
>         },
> )

this work fine.. but is the correct way?
and my other question is How I inject my services class to my controllers
using ServiceInterfaces?




--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Injecting-objects-to-a-controller-or-getting-objects-from-the-service-locator-tp4656872p4657129.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to