Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace AppBundleDataFixturesORM;
- use DoctrineCommonDataFixturesFixtureInterface;
- use DoctrineCommonPersistenceObjectManager;
- use SymfonyComponentDependencyInjectionContainerAwareInterface;
- use SymfonyComponentDependencyInjectionContainerInterface;
- class LoadUserData implements FixtureInterface, ContainerAwareInterface {
- private $container;
- /**
- * Load data fixtures with the passed EntityManager
- *
- * @param ObjectManager $manager
- */
- public function load(ObjectManager $manager)
- {
- $user = new User();
- $user->setLogin('admin');
- $user->setEmail('admin@admin.admin');
- $encoder = $this->container->get('security.password_encoder');
- $password = $encoder->encodePassword($user, '123qwe');
- $user->setPassword($password);
- $manager->persist();
- $manager->flush();
- }
- public function setContainer(ContainerInterface $container = null)
- {
- $this->container = $container;
- }
- }
- namespace AppBundleDataFixturesORM;
- use DoctrineCommonDataFixturesFixtureInterface;
- use DoctrineCommonPersistenceObjectManager;
- use SymfonyComponentDependencyInjectionContainerAwareInterface;
- use SymfonyComponentDependencyInjectionContainerInterface;
- class LoadUserData implements FixtureInterface, ContainerAwareInterface {
- private $container;
- /**
- * Load data fixtures with the passed EntityManager
- *
- * @param ObjectManager $manager
- */
- public function load(ObjectManager $manager)
- {
- $user = new User();
- $user->setLogin('admin');
- $user->setEmail('admin@admin.admin');
- $encoder = $this->container->get('security.password_encoder');
- $password = $encoder->encodePassword($user, '123qwe');
- $user->setPassword($password);
- $manager->persist();
- $manager->flush();
- }
- public function setContainer(ContainerInterface $container = null)
- {
- $this->container = $container;
- }
- }
- parameters:
- services:
- _defaults:
- autowire: true
- autoconfigure: true
- public: false
- AppBundle:
- resource: '../../src/AppBundle/*'
- exclude: '../../src/AppBundle/{Entity,Repository,Tests}'
- AppBundleController:
- resource: '../../src/AppBundle/Controller'
- public: true
- tags: ['controller.service_arguments']
Add Comment
Please, Sign In to add comment