Hi Ralph!

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).


Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/


On 17 March 2013 23:07, Ralf Eggert <[email protected]> wrote:

> Hi,
>
> I missed an important point. My entity class have a method to pass back
> an array with all possible values for the status. This array needs to be
> translated as well, so having the translator injected to an entity would
> make it rather simple. Otherwise a form needs to handle the translations
> when the status options should be set within a form. A simple view
> helper would not help here...
>
> Regards,
>
> Ralf
>
> --
> List: [email protected]
> Info: http://framework.zend.com/archives
> Unsubscribe: [email protected]
>
>
>

Reply via email to