public function load(ObjectManager $manager) { /** @var Team $team1 */ $team1 = $this->getReference('team-1'); for ($i = 1; $i < 11; $i++) { $player = new Player(); $player->setFirstName('FirstName ' . $i); $player->setLastName('LastName ' . $i); $player->setBirthdate(new \DateTime()); $player->setPosition('guard'); $player->addTeam($team1); $manager->persist($player); } $manager->flush(); /** @var Team $team2 */ $team2 = $this->getReference('team-2'); for ($i = 11; $i < 21; $i++) { $player = new Player(); $player->setFirstName('FirstName ' . $i); $player->setLastName('LastName ' . $i); $player->setBirthdate(new \DateTime()); $player->setPosition('guard'); $player->addTeam($team2); $manager->persist($player); } $manager->flush(); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $user = $this->createUser('*****@*****.**', 'sylius', true, ['ROLE_USER', 'ROLE_ADMINISTRATION_ACCESS']); $user->addAuthorizationRole($this->get('sylius.repository.role')->findOneBy(['code' => 'administrator'])); $manager->persist($user); $manager->flush(); $this->setReference('Sylius.User-Administrator', $user); for ($i = 1; $i <= 15; ++$i) { $username = $this->faker->username; while (isset($this->usernames[$username])) { $username = $this->faker->username; } $user = $this->createUser($username . '@example.com', $username, $this->faker->boolean()); $user->setCreatedAt($this->faker->dateTimeThisMonth); $manager->persist($user); $this->usernames[$username] = true; $this->setReference('Sylius.User-' . $i, $user); $this->setReference('Sylius.Customer-' . $i, $user->getCustomer()); } $customer = $this->getCustomerFactory()->createNew(); $customer->setFirstname($this->faker->firstName); $customer->setLastname($this->faker->lastName); $customer->setEmail('*****@*****.**'); $manager->persist($customer); $manager->flush(); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $tipo1 = new Status(); $tipo1->setName("Pendiente"); $manager->persist($tipo1); $manager->flush(); $this->addReference('estado-pendiente', $tipo1); $tipo2 = new Status(); $tipo2->setName("Procesando"); $manager->persist($tipo2); $manager->flush(); $this->addReference('estado-procesando', $tipo2); $tipo3 = new Status(); $tipo3->setName("Enviado"); $manager->persist($tipo3); $manager->flush(); $this->addReference('estado-enviado', $tipo3); $tipo4 = new Status(); $tipo4->setName("Entregado"); $manager->persist($tipo4); $manager->flush(); $this->addReference('estado-entregado', $tipo4); $tipo5 = new Status(); $tipo5->setName("Cancelado"); $manager->persist($tipo5); $manager->flush(); $this->addReference('estado-cancelado', $tipo5); }
/** * Process form * * @param EmailTemplate $entity * * @return bool True on successful processing, false otherwise */ public function process(EmailTemplate $entity) { // always use default locale during template edit in order to allow update of default locale $entity->setLocale($this->defaultLocale); if ($entity->getId()) { // refresh translations $this->manager->refresh($entity); } $this->form->setData($entity); if (in_array($this->request->getMethod(), array('POST', 'PUT'))) { // deny to modify system templates if ($entity->getIsSystem() && !$entity->getIsEditable()) { $this->form->addError(new FormError($this->translator->trans('oro.email.handler.attempt_save_system_template'))); return false; } $this->form->submit($this->request); if ($this->form->isValid()) { // mark an email template creating by an user as editable if (!$entity->getId()) { $entity->setIsEditable(true); } $this->manager->persist($entity); $this->manager->flush(); return true; } } return false; }
public function load(ObjectManager $manager) { $yaml = new Parser(); // TODO: find a way of obtainin Bundle's path with the help of $this->container $bpath = $this->container->get('kernel')->getBundle('SiwappEstimateBundle')->getPath(); $value = $yaml->parse(file_get_contents($bpath . '/DataFixtures/estimates.yml')); foreach ($value['Item'] as $ref => $values) { $item = new Item(); $estimate = new Estimate(); foreach ($values as $fname => $fvalue) { if ($fname == 'Estimate') { $fvalue = $manager->merge($this->getReference($fvalue)); $fvalue->addItem($item); $manager->persist($fvalue); } $method = 'set' . Inflector::camelize($fname); if (is_callable(array($item, $method))) { call_user_func(array($item, $method), $fvalue); } } $manager->persist($item); $manager->flush(); $this->addReference($ref, $item); } foreach ($value['ItemTax'] as $ref => $values) { $item = $this->getReference($values['Item']); $tax = $this->getReference($values['Tax']); $item->addTax($tax); $manager->persist($item); $manager->flush(); } }
/** * "Success" form handler * * @param Role $entity * @param UserInterface[] $appendUsers * @param UserInterface[] $removeUsers */ protected function onSuccess(Role $entity, array $appendUsers, array $removeUsers) { $this->appendUsers($entity, $appendUsers); $this->removeUsers($entity, $removeUsers); $this->manager->persist($entity); $this->manager->flush(); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { // T-Shirts... for ($i = 1; $i <= 120; ++$i) { switch (rand(0, 3)) { case 0: $manager->persist($this->createTShirt($i)); break; case 1: $manager->persist($this->createSticker($i)); break; case 2: $manager->persist($this->createMug($i)); break; case 3: $manager->persist($this->createBook($i)); break; } if (0 === $i % 20) { $manager->flush(); } } $manager->flush(); $this->defineTotalVariants(); }
/** * @param LocationModel $location * @param bool $withFlush */ public function delete(LocationModel $location, $withFlush = true) { $this->objectManager->remove($location); if ($withFlush) { $this->objectManager->flush(); } }
protected function execute(InputInterface $input, OutputInterface $output) { $this->init(); $limit = 50; $offset = 0; $repository = $this->em->getRepository('AppBundle:Sale'); $existingInvoices = $repository->findExistingInvoices(); try { $json = $this->getSales($limit, $offset); $this->saveSales($json['sales'], $existingInvoices); $output->writeln('Saving bunch of sales...'); $total = $json['numSales']; $this->em->flush(); do { $offset += $limit; $json = $this->getSales($limit, $offset); $this->saveSales($json['sales'], $existingInvoices); $output->writeln('Saving bunch of sales...'); $this->em->flush(); } while ($total > $limit + $offset); } catch (\Exception $e) { $output->writeln($e->getMessage()); return; } $output->writeln(sprintf('Imported %s sales', $total)); }
/** * Import Users */ private function importUsers() { $this->output->write(sprintf('%-30s', 'Importing users')); $previewUsers = $this->previewService->getUsers(); $created = 0; $updated = 0; foreach ($previewUsers as $previewUser) { if (!strlen($previewUser->email)) { continue; } /** * @var User $user */ $user = $this->entityManager->getRepository('ProjectPreviewUserBundle:User')->find($previewUser->id); if (is_null($user)) { $user = new User(); $user->setId($previewUser->id); $user->setPassword('toto'); $created++; } else { $updated++; } $user->setEmail($previewUser->email); $user->setUsername($previewUser->email); $user->setLastname($previewUser->lastname); $user->setFirstname($previewUser->firstname); if (isset($previewUser->avatar->urls->avatar_xs)) { $user->setAvatar($previewUser->avatar->urls->avatar_xs); } $this->entityManager->persist($user); } $this->output->writeln(sprintf('done (total: % 4d, created: % 4d, updated: % 4d)', $created + $updated, $created, $updated)); $this->entityManager->flush(); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $data = $this->userFixtureDataSource(); // Have to keep a reference to all the user objects // or else they can't be flushed all at once. $items = array(); $user = new User(); foreach ($data['User'] as $item) { $user = new User(); $user->setUuid($item['uuid'])->setUsername($item['username'])->setPassword($item['password'])->setEmail($item['email'])->setIsActive($item['is_active']); $this->addReference($user->getUuid(), $user); $items[] = $user; $manager->persist($user); } $manager->flush(); $items = array(); foreach ($data['Record'] as $item) { $record = new Record(); $record->setCategory($item['category'])->setKey($item['aKey'])->setData($item['data'])->setOwner($manager->merge($this->getReference($item['owner_uuid']))); $timestamp = new \DateTime('now'); if (!empty($item['timestamp'])) { $timestamp->setTimestamp($item['timestamp']); } $record->setTimestamp($timestamp); $items[] = $record; $manager->persist($record); } $manager->flush(); }
/** * @param \Doctrine\Common\Persistence\ObjectManager $manager * @param $locale */ public function createMenuItems(ObjectManager $manager, $locale) { $menuRoot = new MenuItem(); $menuRoot->setName('Main menu'); $menuRoot->setLocale($locale); $menuRoot->setIsRoot(true); $menuRoot->setLvl(1); $menuRoot->setLft(1); $menuRoot->setRgt(2); $manager->persist($menuRoot); $manager->flush(); $homePageMenu = new MenuItem(); $homePageMenu->setName('Homepage'); $homePageMenu->setPage($this->getReference('homepage_' . $locale)); $homePageMenu->setParent($menuRoot); $manager->persist($homePageMenu); $manager->flush(); $footerRoot = new MenuItem(); $footerRoot->setName('Footer menu'); $footerRoot->setLocale($locale); $footerRoot->setIsRoot(true); $footerRoot->setLvl(1); $footerRoot->setLft(1); $footerRoot->setRgt(2); $manager->persist($footerRoot); $manager->flush(); }
public function load(ObjectManager $manager) { // Les variables $listCours = array('Français', 'Math', 'Allemand'); $classeName = "8P7"; $classeDescription = "La classe 8P7 de Mme Gomez"; $classe = new Classe(); $classe->setName($classeName); $classe->setDescription($classeDescription); $manager->persist($classe); $manager->flush(); $em = $this->container->get('doctrine')->getEntityManager('default'); $repository = $em->getRepository('Sulaz1xSecurityBundle:User'); $students = $repository->findAll(); foreach ($students as $student) { $student->setClasse($classe); $manager->persist($student); } foreach ($listCours as $coursname) { // On crée l'utilisateur $cours = new Cours(); // Le nom d'utilisateur et le mot de passe sont identiques $cours->setName($coursname); $cours->setDescription("Un cours de test"); $cours->setStart(new \Datetime('25-08-2015')); $cours->setEnd(new \Datetime('25-07-2016')); $classe->addCours($cours); $manager->persist($cours); $manager->persist($classe); } // On déclenche l'enregistrement $manager->flush(); }
public function load(ObjectManager $manager) { $category1 = new Categories(); $category1->setName("DECORATION"); $category1->setCreated(new \DateTime('now ')); $category1->setUpdated(new \DateTime('now ')); $this->addReference("category1", $category1); $manager->persist($category1); $manager->flush(); $category2 = new Categories(); $category2->setName("TABLEAUX"); $category2->setCreated(new \DateTime('now ')); $category2->setUpdated(new \DateTime('now ')); $this->addReference("category2", $category2); $manager->persist($category2); $manager->flush(); $category3 = new Categories(); $category3->setName("BOUGEOIRS"); $category3->setCreated(new \DateTime('now ')); $category3->setUpdated(new \DateTime('now ')); $this->addReference("category3", $category3); $manager->persist($category3); $manager->flush(); $category4 = new Categories(); $category4->setName("MAISON"); $category4->setCreated(new \DateTime('now ')); $category4->setUpdated(new \DateTime('now ')); $this->addReference("category4", $category4); $manager->persist($category4); $manager->flush(); }
public function load(ObjectManager $manager) { $projectPhoto = new ProjectPhoto(); $projectPhoto->setFilename('slide1.jpg'); $projectPhoto->setProject($this->getReference('project1')); $manager->persist($projectPhoto); $manager->flush(); $projectPhoto = new ProjectPhoto(); $projectPhoto->setFilename('slide2.jpg'); $projectPhoto->setProject($this->getReference('project1')); $manager->persist($projectPhoto); $manager->flush(); $projectPhoto = new ProjectPhoto(); $projectPhoto->setFilename('slide3.jpg'); $projectPhoto->setProject($this->getReference('project1')); $manager->persist($projectPhoto); $manager->flush(); $projectPhoto = new ProjectPhoto(); $projectPhoto->setFilename('slide4.jpg'); $projectPhoto->setProject($this->getReference('project1')); $manager->persist($projectPhoto); $manager->flush(); $projectPhoto = new ProjectPhoto(); $projectPhoto->setFilename('slide5.jpg'); $projectPhoto->setProject($this->getReference('project1')); $manager->persist($projectPhoto); $manager->flush(); }
/** * Save $userAnswers in db */ public function saveUserAnswers() { foreach ($this->userAnswers as $userAnswer) { $this->em->persist($userAnswer); } $this->em->flush(); }
/** * @param \Doctrine\Common\Persistence\ObjectManager $manager * @param $locale */ public function createLayoutBlocks(ObjectManager $manager, $locale) { $textClass = false; $contentTypes = $this->container->getParameter('networking_init_cms.page.content_types'); foreach ($contentTypes as $type) { if ($type['name'] == 'Text') { $textClass = $type['class']; break; } } if (!$textClass) { return; } $layoutBlock = new LayoutBlock(); $layoutBlock->setIsActive(true); $layoutBlock->setSortOrder(1); $layoutBlock->setClassType($textClass); $layoutBlock->setZone($this->getFirstZone()); $layoutBlock->setPage($this->getReference('homepage_' . $locale)); $manager->persist($layoutBlock); $manager->flush(); /** @var TextInterface $text */ $text = new $textClass(); $text->setText('<h1>Hello World</h1><p>The locale of this page is ' . $locale . '</p>'); $manager->persist($text); $manager->flush(); $layoutBlock->setObjectId($text->getId()); $manager->persist($layoutBlock); $manager->flush(); }
/** * @param Message $message */ public function process(Message $message) { // Only process messages where ShareMonkey is mentioned if ($this->shareMonkeyIsMentioned($message->getText()) === false) { return; } $text = $message->getText(); $urls = $text->getUrls(); $tags = $text->getTags(); if (count($urls) === 0) { $this->logger->debug('No urls found in message'); return; } $user = $this->userRepository->findOneBySlackId($message->getUserId()); if (!$user instanceof User) { $this->logger->error(sprintf('User "%s" not found', $message->getUserId()->getValue())); return; } foreach ($urls as $url) { $this->logger->debug(sprintf('processing url %s', $url)); $info = Embed::create($url); $link = Link::fromSlack($message->getId(), $user, $message->getCreatedAt(), $info->getTitle() ?: $message->getText(), $url, $tags); $this->objectManager->persist($link); $this->objectManager->flush(); $this->objectManager->clear(); $this->logger->debug(sprintf('Saved link %s', $link->getUrl())); } }
/** * @param Message $message * @param callable $next */ public function handle($message, callable $next) { $next($message); $this->logger->debug(sprintf('CommitsObjectManagerTransaction flushes Object manager after handling command "%s"', $message instanceof NamedMessage ? $message::messageName() : get_class($message))); $this->om->flush(); $this->logger->debug(sprintf('CommitsObjectManagerTransaction finished handling "%s"', $message instanceof NamedMessage ? $message::messageName() : get_class($message))); }
/** * @param OrderInterface $order */ private function updateExistingPaymentsStates(OrderInterface $order) { foreach ($order->getPayments() as $payment) { $this->cancelPaymentStateIfNotStarted($payment); } $this->paymentManager->flush(); }
public function load(ObjectManager $manager) { foreach (range(0, 29) as $i) { $purchase = new Purchase(); $purchase->setGuid($this->generateGuid()); $purchase->setDeliveryDate(new \DateTime("+{$i} days")); $purchase->setCreatedAt(new \DateTime("now +{$i} seconds")); $purchase->setShipping(new \StdClass()); $purchase->setDeliveryHour($this->getRandomHour()); $purchase->setBillingAddress(json_encode(array('line1' => '1234 Main Street', 'line2' => 'Big City, XX 23456'))); $purchase->setBuyer($this->getReference('user-' . $i % 20)); $this->addReference('purchase-' . $i, $purchase); $manager->persist($purchase); $manager->flush(); $numItemsPurchased = rand(1, 5); foreach (range(1, $numItemsPurchased) as $j) { $item = new PurchaseItem(); $item->setQuantity(rand(1, 3)); $item->setProduct($this->getRandomProduct()); $item->setTaxRate(0.21); $item->setPurchase($this->getReference('purchase-' . $i)); $manager->persist($item); } } $manager->flush(); }
/** * Flushes all loaded cart and related entities. * * We only persist it if have lines loaded inside, so empty carts will never * be persisted * * @param CartInterface $cart Cart */ public function saveCart(CartInterface $cart) { if (!$cart->getCartLines()->isEmpty()) { $this->cartObjectManager->persist($cart); } $this->cartObjectManager->flush(); }
/** * Load data fixtures with the passed EntityManager * * @param \Doctrine\Common\Persistence\ObjectManager $manager */ function load(ObjectManager $manager) { $typeRepo = $manager->getRepository('GotChosenSiteBundle:NotificationCommType'); $general = $typeRepo->findOneBy(['typeName' => 'General Notifications']); if (!$general) { $general = new NotificationCommType(); $general->setTypeName('General Notifications'); $manager->persist($general); } $eg = $typeRepo->findOneBy(['typeName' => 'Evolution Games Notifications']); if (!$eg) { $eg = new NotificationCommType(); $eg->setTypeName('Evolution Games Notifications'); $manager->persist($eg); } $manager->flush(); $notificationTypes = [['Newsletters', $general, true], ['Scholarship Information', $general, false], ['Sponsor Notifications', $general, false], ['Developer Feedback Notifications', $eg, false], ['Scholarship Notifications', $eg, false], ['EG News', $eg, false]]; $repo = $manager->getRepository('GotChosenSiteBundle:NotificationType'); foreach ($notificationTypes as $nt) { if (!$repo->findOneBy(['name' => $nt[0]])) { $type = new NotificationType(); $type->setName($nt[0]); $type->setCommType($nt[1]); $type->setIsDefault($nt[2]); $manager->persist($type); } } $manager->flush(); }
/** * Load fixtures * * @param ObjectManager $manager Manager */ public function load(ObjectManager $manager) { $user1 = new User(); $user1->setUsername('user_1'); $user1->setEmail('*****@*****.**'); $user1->setPlainPassword('user_1'); $user1->setGithubId('some_id'); $manager->persist($user1); $manager->flush(); $user2 = new User(); $user2->setUsername('user_2'); $user2->setPlainPassword('user_2'); $user2->setGithubId('some_id'); $user2->setEmail('*****@*****.**'); $manager->persist($user2); $manager->flush(); $user3 = new User(); $user3->setUsername('user_3'); $user3->setPlainPassword('user_3'); $user3->setGithubId('some_id'); $user3->setEmail('*****@*****.**'); $manager->persist($user3); $manager->flush(); $this->addReference('user_1', $user1); $this->addReference('user_2', $user2); $this->addReference('user_3', $user3); }
public function load(ObjectManager $manager) { $yaml = new Parser(); $bpath = $this->container->get('kernel')->getBundle('SiwappRecurringInvoiceBundle')->getPath(); $value = $yaml->parse(file_get_contents($bpath . '/DataFixtures/recurring_invoices.yml')); foreach ($value['Item'] as $ref => $values) { $item = new Item(); $recurring_invoice = new RecurringInvoice(); foreach ($values as $fname => $fvalue) { if ($fname == 'RecurringInvoice') { $fvalue = $manager->merge($this->getReference($fvalue)); } $method = 'set' . Inflector::camelize($fname); if (is_callable(array($item, $method))) { call_user_func(array($item, $method), $fvalue); } } $manager->persist($item); $manager->flush(); $this->addReference($ref, $item); } foreach ($value['ItemTax'] as $ref => $values) { $item = $this->getReference($values['Item']); $tax = $this->getReference($values['Tax']); $item->addTax($tax); $manager->persist($item); $manager->flush(); } }
public function load(ObjectManager $manager) { $faker = Factory::create(); for ($i = 1; $i <= 24; $i++) { $team = new Team(); $team->setInfo($faker->text(2000)); $country = $this->getReference("country {$i}"); $team->setCountry($country); $this->setReference("team {$i}", $team); $manager->persist($team); $manager->flush(); for ($k = 1; $k <= 11; $k++) { $player = new Player(); $player->setFirstName($faker->firstNameMale); $player->setLastName($faker->lastName); $player->setBiography($faker->text(200)); $player->setDateOfBirthday($faker->date('Y-m-d')); $player->setTeam($team); $team->getPlayers()->add($player); $manager->persist($player); } // the same for coaches for ($k = 1; $k <= 5; $k++) { $coach = new Coach(); $coach->setName($faker->name); $coach->setBiography($faker->text(200)); $coach->setTeam($team); $team->getCoaches()->add($coach); $manager->persist($coach); } } $manager->flush(); }
public function load(ObjectManager $manager) { $faker = Factory::create(); for ($i = 0; $i < 50; $i++) { static $id = 1; $post = new Post(); $post->setTitle($faker->sentence); $post->setAuthorEmail('*****@*****.**'); $post->setImageName("images/post/foto{$id}.jpg"); $post->setContent($faker->realText($maxNbChars = 5000, $indexSize = 2)); $marks = array(); for ($q = 0; $q < rand(1, 10); $q++) { $marks[] = rand(1, 5); } $post->setMarks($marks); $post->addMark(5); $manager->persist($post); $this->addReference("{$id}", $post); $id = $id + 1; $rand = rand(3, 7); for ($j = 0; $j < $rand; $j++) { $comment = new Comment(); $comment->setAuthorEmail('*****@*****.**'); $comment->setCreatedBy('user_user'); $comment->setContent($faker->realText($maxNbChars = 500, $indexSize = 2)); $comment->setPost($post); $post->getComments()->add($comment); $manager->persist($comment); $manager->flush(); } } $manager->flush(); }
public function load(ObjectManager $manager) { $p1 = new Post(); $p1->setDate(new \DateTime()); $p1->setTitle("Man must explore, and this is exploration at its greatest"); $p1->setSubtitle("Problems look mighty small from 150 miles up"); $p1->setSubject("Using the translation tags or filters have the same effect, but with one subtle difference: automatic output escaping is only applied to translations using a filter. In other words, if you need to be sure that your translated message is not output escaped, you must apply the raw filter after the translation filter: "); $manager->persist($p1); $manager->flush(); $p2 = new Post(); $p2->setDate(new \DateTime()); $p2->setTitle("I believe every human has a finite number of heartbeats. I don't intend to waste any of mine. "); $p2->setSubtitle("The locations are listed here with the highest priority first "); $p2->setSubject("Using the translation tags or filters have the same effect, but with one subtle difference: automatic output escaping is only applied to translations using a filter. In other words, if you need to be sure that your translated message is not output escaped, you must apply the raw filter after the translation filter: "); $manager->persist($p2); $manager->flush(); $p3 = new Post(); $p3->setDate(new \DateTime()); $p3->setTitle("Man must explore, and this is exploration at its greatest"); $p3->setSubtitle("Problems look mighty small from 150 miles up"); $p3->setSubject("Translation Resource/File Names and Locations Symfony looks for message files (i.e. translations) in the following locations: the app/Resources/translations directory; the app/Resources/<bundle name>/translations directory; the Resources/translations/ directory inside of any bundle. The locations are listed here with the highest priority first. That is, you can override the translation messages of a bundle in any of the top 2 directories. The override mechanism works at a key level: only the overridden keys need to be listed in a higher priority message file. When a key is not found in a message file, the translator will automatically fall back to the lower priority message files. "); $manager->persist($p3); $manager->flush(); for ($i = 0; $i < 50; $i++) { $px = new Post(); $px->setDate(new \DateTime()); $px->setTitle("Man must explore, and this is exploration at its greatest "); $px->setSubtitle("Problems look mighty small from 150 miles up"); $px->setSubject("Translation Resource/File Names and Locations Symfony looks for message files (i.e. translations) in the following locations: the app/Resources/translations directory; the app/Resources/<bundle name>/translations directory; the Resources/translations/ directory inside of any bundle. The locations are listed here with the highest priority first. That is, you can override the translation messages of a bundle in any of the top 2 directories. The override mechanism works at a key level: only the overridden keys need to be listed in a higher priority message file. When a key is not found in a message file, the translator will automatically fall back to the lower priority message files. "); $manager->persist($px); $manager->flush(); } }
/** * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $user = new User(); $user->setFirstName('Admin'); $user->setLastName('User'); $user->setUsername('admin'); $user->setEmail('*****@*****.**'); $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $user->setPassword($encoder->encodePassword('mautic', $user->getSalt())); $user->setRole($this->getReference('admin-role')); $manager->persist($user); $manager->flush(); $this->addReference('admin-user', $user); $user = new User(); $user->setFirstName('Sales'); $user->setLastName('User'); $user->setUsername('sales'); $user->setEmail('*****@*****.**'); $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $user->setPassword($encoder->encodePassword('mautic', $user->getSalt())); $user->setRole($this->getReference('sales-role')); $manager->persist($user); $manager->flush(); $this->addReference('sales-user', $user); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $user = new User(); $user->setUsername('admin'); $user->setEmail('*****@*****.**'); $user->setEnabled(true); $user->setRoles(array('ROLE_SUPER_ADMIN')); $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $user->setPassword($encoder->encodePassword('admin', $user->getSalt())); $manager->persist($user); $manager->flush(); $this->addReference('user1', $user); $user = new User(); $user->setUsername('o.quiroz'); $user->setEmail('*****@*****.**'); $user->setEnabled(true); $user->setRoles(array('ROLE_SUPER_ADMIN')); $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $user->setPassword($encoder->encodePassword('o.quiroz', $user->getSalt())); $manager->persist($user); $manager->flush(); $this->addReference('user2', $user); $user = new User(); $user->setUsername('n.ramirez'); $user->setEmail('*****@*****.**'); $user->setEnabled(true); $user->setRoles(array('ROLE_SUPER_ADMIN')); $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $user->setPassword($encoder->encodePassword('o.quiroz', $user->getSalt())); $manager->persist($user); $manager->flush(); $this->addReference('user3', $user); }