Hi Marco,

> I think that injecting anything in an entity is a bad practice.
> An entity (for me) is more similar to a value object with an identifier, so
> you should not move logic to it.
> Instead, consider using a wrapper for the entity:
> 
> class MyEntity
> {
>     // ...
> }
> 
> class MyTranslatedEntity
> {
>     public function __construct(MyEntity $entity, Translator $translator)
>     {
>         // ...
>     }
> }
> 
> This may well happen in a hydrator (since the hydrator doesn't need to
> return the original entity instance).

Thanks for your suggestion. After having some sleep I noticed myself
that injecting the translator into an entity is one of the baddest ideas
I had in the last weeks... ;-)

The entity now will hold a list of possible status options like suche:

array(
  'new'      => 'user_option_status_new',
  'approved' => 'user_option_status_approved',
  'blocked'  => 'user_option_status_blocked',
);

The translation of these options will be done when the form is
displayed. So the translation will take place in the view like all other
translations as well...

Thanks and regards,

Ralf

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


Reply via email to