Actually, that won't work. You're right that you need something that has
access to the entity manager.

I believe what you'll need to do is create a custom constraint and validator
(
http://symfony.com/doc/2.0/cookbook/validation/custom_constraint.html#constraint-validators-with-dependencies),
and pass in the entity manager as a constraint to your validator.

It seems like there should be an easier way, but I don't think that the
callback is container aware, meaning you can't use the callback to point to
a validator that is a service. But I'm hoping someone will correct me :)

Thanks!

Ryan Weaver
US Office Head & Trainer - KnpLabs - Nashville, TN
http://www.knplabs.com <http://www.knplabs.com/en>
http://www.thatsquality.com
Twitter: @weaverryan


On Fri, Sep 16, 2011 at 6:52 AM, 7 Habitos <[email protected]> wrote:

> You have to use Dependency Inyector like that:
>
> use Symfony\Component\DependencyInjection\ContainerAware;
>
> class..{
>
>    public function..{
>        $container = new ContainerAware();
>        $emUserType = $this->container->get('Doctrine')-
> >getEntityManager();
>        ...
>    }
> }
>
> Try this, I don“t probe yet
>
> --
> 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
>

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