Hi Carlos,

2011/1/30 Carlos Sánchez <[email protected]>

> Hi all,
> Need to gain access to the services that DIC provides,
> (entity_manager, event_manager, etc..) from my classes (entity class).
> How do I do it?
> Controller class extends ContainerAware, will that be enough?,
> extending ContainerAware from classes i need to gain access to DIC? Is
> that to proper way to do it?
>

I'll tag along with the other posters in saying that there is probably a way
to do it. Nevertheless, this is a very strong code smell.

Are your entities domain objects ? If the answer is yes, you almost
certainly should not be accessing the DIC, since its interface belongs to
the application layer. You should inject -from- the application layer to
domain services, not entities (entities use services). If, on the other
hand, your entities belong to the application layer (e.g. for cross-cutting
concerns like identity management), services should be injected in your
entities, not the contrary, although I'm almost certain this is still a bad
practice (but far less damaging than if it is done on the domain layer). You
are trying to use the DIC as a Service Locator, which is a use case it was
not designed for.


>
> Thanks in advanced.
>
> --
> 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 developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<symfony-devs%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
>



-- 
Nicolas A. Bérard-Nault ([email protected])

-- 
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 developers" 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-devs?hl=en

Reply via email to