Le 01/06/2011 15:41, FractalizeR a écrit :
Hello.
I'm writing some fixtures to load test users into db while testing.
And to set password on the user I need to get required encoder from
factory. And to get encoder factory I need, as I understand, to query
Service container. How to do that from the fixture?
Fixture doesn't have any get() method to access service container so I
cannot do this:
| $user = new User();
$user->setEmail('[email protected]');
$user->setPassword('password{AAAAA}');
$user->setSalt('AAAAA');
$factory = $user->get('security.encoder_factory');
$encoder = $factory->getEncoder($user);
$password = $encoder->encodePassword('ryanpass',
$user->getSalt());
$user->setPassword($password);
$manager->persist($user);
$manager->flush();|
Is there another way to get service container?
Thanks.
Implementes the
Symfony\Component\DependencyInjection\ContainerAwareInterface in your
fixtures and the container will be injected in your class before calling
the load() method.
--
Christophe | Stof
--
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