当前位置: 首页>>代码示例>>PHP>>正文


PHP Persistence\ObjectManager类代码示例

本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager类的具体用法?PHP ObjectManager怎么用?PHP ObjectManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $adminConfig = new Config($this->getReference('admin-user'));
     $adminConfig->setTheme('material');
     $adminConfig->setItemsPerPage(30);
     $adminConfig->setReadingSpeed(1);
     $adminConfig->setLanguage('en');
     $adminConfig->setPocketConsumerKey('xxxxx');
     $manager->persist($adminConfig);
     $this->addReference('admin-config', $adminConfig);
     $bobConfig = new Config($this->getReference('bob-user'));
     $bobConfig->setTheme('default');
     $bobConfig->setItemsPerPage(10);
     $bobConfig->setReadingSpeed(1);
     $bobConfig->setLanguage('fr');
     $bobConfig->setPocketConsumerKey(null);
     $manager->persist($bobConfig);
     $this->addReference('bob-config', $bobConfig);
     $emptyConfig = new Config($this->getReference('empty-user'));
     $emptyConfig->setTheme('material');
     $emptyConfig->setItemsPerPage(10);
     $emptyConfig->setReadingSpeed(1);
     $emptyConfig->setLanguage('en');
     $emptyConfig->setPocketConsumerKey(null);
     $manager->persist($emptyConfig);
     $this->addReference('empty-config', $emptyConfig);
     $manager->flush();
 }
开发者ID:wallabag,项目名称:wallabag,代码行数:31,代码来源:LoadConfigData.php

示例2: load

 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setFirstName('Admin');
     $user->setLastName('User');
     $user->setUsername('admin');
     $user->setEmail('admin@yoursite.com');
     $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('sales@yoursite.com');
     $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);
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:28,代码来源:LoadUserData.php

示例3: __construct

 public function __construct($class, ObjectManager $om)
 {
     $this->objectManager = $om;
     $this->repository = $om->getRepository($class);
     $metadata = $om->getClassMetadata($class);
     $this->class = $metadata->getName();
 }
开发者ID:lsroudi,项目名称:classifiedads,代码行数:7,代码来源:AdManager.php

示例4: load

 public function load(ObjectManager $manager)
 {
     // sports
     $titre1 = new Chant();
     $titre1->setTitre('Angie');
     $titre1->setResume('Chanson française');
     $titre1->setDateRedaction(new \Datetime());
     $titre1->setType('Classique');
     $titre1->setPublication(true);
     $titre2 = new Chant();
     $titre2->setTitre('Willy Lynch');
     $titre2->setResume('Mix franco anglais');
     $titre2->setDateRedaction(new \Datetime());
     $titre2->setType('RNB');
     $titre2->setPublication(true);
     $titre3 = new Chant();
     $titre3->setTitre('Avant de partir');
     $titre3->setDateRedaction(new \Datetime());
     $titre3->setResume('Mix franco anglais');
     $titre3->setType('Classique');
     $titre3->setPublication(false);
     // On déclenche l'enregistrement
     $manager->persist($titre1);
     $manager->persist($titre2);
     $manager->persist($titre3);
     $manager->flush();
 }
开发者ID:messi1983,项目名称:messi-repo,代码行数:27,代码来源:Chants.php

示例5: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $data = array('Apéritif' => array('10 Petits croissants au saumon' => '4.00', '6 Beignets de morue' => '3.00', '6 Rissoes à la viande ou aux crevettes' => '3.00', '20 Roulés saucisses ou divers petits fours' => '3.00', 'Cake jambon/olives ou saumon ou thon' => '4.00', '10 Navettes garnies ( jambon, fromage, paté etc...)' => '3.00'), 'Entrée' => array('Coquille Saint Jacques' => '3.50', 'Coquille aux fruits de mer' => '2.40', 'Quiche lorraine (6 parts)' => '3.50', 'Quiche saumon-brocolis ou saumon-poireaux' => '4.50'), 'Sur le pouce' => array('Ficelle Picarde' => '2.50', 'Croque Madame' => '1.50', 'Couronne de jambon, fromage (6 parts)' => '7.50', 'Crêpe au sarazin garnie' => '2.50', 'Hamburger' => '2.50', 'Pizza' => '5.00'), 'Pâtes' => array('6 Cannellonis chêvre, épinards' => '4.50', 'Spaguettis bolognaise' => '4.50', 'Lasagnes viande tomate ou saumon épinards' => '4.50', 'Tagliatelles carbonara' => '4.50', 'Pâtes à la Rosa' => '4.50', 'Pennes aux 4 fromages' => '4.50', 'Tagliatelles au saumon' => '4.50', 'Pâtes aux fruits de mer' => '4.50'), 'Plats' => array('Hachis parmentier' => '5.00', 'Endives au gratin (jambon, pommes de terre)' => '5.00', 'Tartiflette' => '5.00', 'Morue à la crème, pomme de terre, épinards ou pas' => '5.00', 'Rata aux poireaux, pomme de terre, sauté de porc' => '5.00', 'Escalope de porc panée avec riz et légumes' => '5.00', 'Rouelle avec pomme de terre au four' => '5.00', 'Brandade de morue parmentière' => '5.00', 'Fricassée de volaille à l\'ancienne, riz pilaf' => '5.00', 'Pomme de terre macaire (jambon-fromage)' => '5.00', 'Gratin dauphinois au jambon' => '5.00', 'Risotto aux fruits de mer' => '5.00', 'Risotto poulet, champignons' => '5.00', 'Chou rouge cuit avec pomme et saucisse' => '5.00', 'Tomate farçie en sauce, riz ou pâtes au choix' => '6.00', 'Courgette farcie garniture au choix' => '6.00', 'Paêlla' => '7.00', 'Bœuf bourguignon avec pâtes ou purée' => '7.00', 'Bœuf strogonof (tomate crème moutarde), garniture au choix' => '7.00', 'Carbonnade flamande avec garniture' => '7.00', 'Langue de bœuf, pomme de terre, légumes, sauce' => '7.00', 'Roti de porc Orloff, garniture au choix' => '7.00', 'Filet mignon, pomme de terre, endive, sauce maroille' => '7.00', 'Choucroute viande ou poisson, pommes vapeur' => '7.00', 'Parmentier de canard' => '8.00', 'Veau marengo, garniture au choix' => '8.00', 'Couscous 3 viandes(mouton ou bœuf, poulet, merguez)' => '8.00', 'Cassoulet au canard' => '8.00', 'Tripes à la portugaise avec du riz' => '8.00', 'Blanquette de veau à l\'ancienne, garniture au choix' => '8.00', 'Poulpe mijoté aux légumes, pomme de terre' => '8.00'), 'Desserts' => array('Pudding portugais (8 parts)' => '6.00', '6 pasteis de natas' => '4.00', 'Tarte aux fruits (6 personnes)' => '4.00'));
     foreach ($data as $categoryName => $meals) {
         $category = $this->get('doctrine')->getRepository('AppBundle:Category')->findOneByName($categoryName);
         if (!$category) {
             throw new \InvalidArgumentException(sprintf('Found no category with name "%s".', $categoryName));
         }
         $position = 0;
         foreach ($meals as $name => $mealData) {
             $position++;
             if (is_string($mealData)) {
                 $mealData = array('price' => $mealData);
             }
             $mealData = array_merge(array('description' => null), $mealData);
             $meal = new Meal();
             $meal->setName($name)->setCategory($category)->setDescription($mealData['description'])->setPrice(new Price($mealData['price']))->setPosition($position);
             if (isset($mealData['active'])) {
                 $meal->setActive($mealData['active']);
             }
             $manager->persist($meal);
         }
     }
     $manager->flush();
 }
开发者ID:alexandresalome,项目名称:site-de-maman,代码行数:28,代码来源:LoadMealData.php

示例6: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $manager->persist($this->createPaymentMethod('PM1', 'Offline', 'offline'));
     $manager->persist($this->createPaymentMethod('PM2', 'PaypalExpressCheckout', 'paypal_express_checkout'));
     $manager->persist($this->createPaymentMethod('PM5', 'StripeCheckout', 'stripe_checkout'));
     $manager->flush();
 }
开发者ID:starspire,项目名称:eventmanager,代码行数:10,代码来源:LoadPaymentMethodsData.php

示例7: loadEmailsDemo

 /**
  * @param ObjectManager $om
  */
 protected function loadEmailsDemo(ObjectManager $om)
 {
     $contacts = $om->getRepository('OroCRMContactBundle:Contact')->findAll();
     $contactCount = count($contacts);
     for ($i = 0; $i < 100; ++$i) {
         $contactRandom = rand(0, $contactCount - 1);
         /** @var Contact $contact */
         $contact = $contacts[$contactRandom];
         $owner = $contact->getOwner();
         $origin = $this->mailerProcessor->getEmailOrigin($owner->getEmail());
         $randomTemplate = array_rand($this->templates);
         $emailUser = $this->addEmailUser($randomTemplate, $owner, $contact, $origin);
         if ($i % 7 == 0) {
             $thread = new EmailThread();
             $om->persist($thread);
             $emailUser->getEmail()->setThread($thread);
             $randomNumber = rand(1, 7);
             for ($j = 0; $j < $randomNumber; ++$j) {
                 $eu = $this->addEmailUser($randomTemplate, $owner, $contact, $origin);
                 $eu->getEmail()->setSubject('Re: ' . $emailUser->getEmail()->getSubject());
                 $eu->getEmail()->setThread($thread);
                 $eu->getEmail()->setHead(false);
             }
         }
         $this->emailEntityBuilder->getBatch()->persist($om);
     }
 }
开发者ID:rodolfobandeira,项目名称:crm,代码行数:30,代码来源:LoadEmailData.php

示例8: load

 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();
 }
开发者ID:pinoniq,项目名称:tritonleuven.be,代码行数:27,代码来源:LoadPlayerData.php

示例9: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setName('TEST LIKES');
     $manager->persist($userAdmin);
     $manager->flush();
 }
开发者ID:JupiterSky,项目名称:liketest,代码行数:10,代码来源:LoadUserData.php

示例10: load

 public function load(ObjectManager $manager)
 {
     // Les noms d'utilisateurs à créer
     $listNames = array('Antoine', 'Michel', 'Manessa');
     foreach ($listNames as $name) {
         // On crée l'utilisateur
         $user = new User();
         // Le nom d'utilisateur et le mot de passe sont identiques
         $user->setUsername($name);
         $user->setPassword($name);
         // On ne se sert pas du sel pour l'instant
         $user->setSalt('');
         if ($name == "Antoine") {
             // On met ROLE_ADMIN pour Antoine
             $user->setRoles(array('ROLE_ADMIN'));
         } else {
             //et le ROLE_USER pour les autres
             $user->setRoles(array('ROLE_USER'));
         }
         // On le persiste
         $manager->persist($user);
     }
     // On déclenche l'enregistrement
     $manager->flush();
 }
开发者ID:antoineginsburg,项目名称:agenceImmoDemo,代码行数:25,代码来源:LoadUser.php

示例11: load

 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();
 }
开发者ID:timy-life,项目名称:easy-admin-demo,代码行数:26,代码来源:LoadPurchases.php

示例12: load

 public function load(ObjectManager $manager)
 {
     // Obtener todas las ciudades de la base de datos
     $ciudades = $manager->getRepository('CiudadBundle:Ciudad')->findAll();
     for ($i = 1; $i <= 500; $i++) {
         $usuario = new Usuario();
         $usuario->setNombre($this->getNombre());
         $usuario->setApellidos($this->getApellidos());
         $usuario->setEmail('usuario' . $i . '@localhost');
         $usuario->setSalt(md5(time()));
         $passwordEnClaro = 'usuario' . $i;
         $encoder = $this->container->get('security.encoder_factory')->getEncoder($usuario);
         $passwordCodificado = $encoder->encodePassword($passwordEnClaro, $usuario->getSalt());
         $usuario->setPassword($passwordCodificado);
         $usuario->setDireccion('Gran Vía, ' . rand(1, 250));
         // El 60% de los usuarios permite email
         $usuario->setPermiteEmail(rand(1, 1000) % 10 < 6);
         $usuario->setFechaAlta(new \DateTime('now - ' . rand(1, 150) . ' days'));
         $usuario->setFechaNacimiento(new \DateTime('now - ' . rand(7000, 20000) . ' days'));
         $dni = substr(rand(), 0, 8);
         $usuario->setDni($dni . substr("TRWAGMYFPDXBNJZSQVHLCKE", strtr($dni, "XYZ", "012") % 23, 1));
         $usuario->setNumeroTarjeta('1234567890123456');
         $usuario->setCiudad($ciudades[array_rand($ciudades)]);
         $manager->persist($usuario);
     }
     $manager->flush();
 }
开发者ID:rodrigogvillarreal,项目名称:Cupon,代码行数:27,代码来源:Usuarios.php

示例13: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $em)
 {
     $stream = fopen(__DIR__ . '/../Data/terrains.csv', 'r');
     while ($line = fgets($stream)) {
         $data = explode(';', $line);
         $entity = new Terrain();
         $entity->setICAO(str_replace('"', '', $data[1]));
         $entity->setIATA(str_replace('"', '', $data[2]));
         $entity->setTown(str_replace('"', '', $data[3]));
         $entity->setCity(str_replace('"', '', $data[4]));
         $entity->setCountry(str_replace('"', '', $data[5]));
         $entity->setLatitude(str_replace(',', '.', str_replace('"', '', $data[6])));
         $entity->setLongitude(str_replace(',', '.', str_replace('"', '', $data[7])));
         $entity->setAltitude(str_replace('"', '', $data[8]));
         $entity->setTimezone(str_replace('"', '', $data[9]));
         $entity->setDac(str_replace('"', '', $data[10]));
         $entity->setDepartement(str_replace('"', '', $data[12]));
         $entity->setRestreint(str_replace('"', '', $data[13]));
         $entity->setUlm(str_replace('"', '', $data[14]));
         $entity->setHeliStation(str_replace('"', '', $data[15]));
         $entity->setVac(str_replace('"', '', $data[16]));
         $entity->setTouchAndGoPrice(str_replace('"', '', $data[17]));
         $entity->setLandingPrice(str_replace('"', '', $data[18]));
         $entity->setDayLawnPrice(str_replace('"', '', $data[19]));
         $entity->setHangarPrice(str_replace('"', '', $data[20]));
         $entity->setAltiport(str_replace('"', '', $data[21]));
         $entity->setRegion(str_replace('"', '', $data[22]));
         $entity->setName(str_replace('"', '', $data[23]));
         $entity->setPublished(true);
         $entity->setCreatedAt(new \DateTime());
         $em->persist($entity);
     }
     fclose($stream);
     $em->flush();
 }
开发者ID:sev28,项目名称:flyaround_s2,代码行数:38,代码来源:LoadTerrainData.php

示例14: load

 public function load(ObjectManager $manager)
 {
     $filename = "src/BuddySystem/MainBundle/DataFixtures/SQL/sections.sql";
     $sql = file_get_contents($filename);
     $manager->getConnection()->exec($sql);
     $manager->flush();
 }
开发者ID:ESNFranceG33kTeam,项目名称:sf_buddysystem,代码行数:7,代码来源:LoadSectionsData.php

示例15: load

 public function load(ObjectManager $manager)
 {
     /* @var $userService \ZfcUser\Service\User */
     $userService = $this->getServiceLocator()->get('zfcuser_user_service');
     $data = array('username' => 'xelax90', 'display_name' => 'Xelax 90', 'email' => 'schurix@gmx.de', 'password' => 'schurix', 'passwordVerify' => 'schurix');
     $found = $userService->getUserMapper()->findByEmail($data['email']);
     if ($found) {
         $this->addReference('admin-user', $found);
         return;
     }
     /* @var $options \SkelletonApplication\Options\SiteRegistrationOptions */
     $options = $this->getServiceLocator()->get(\SkelletonApplication\Options\SiteRegistrationOptions::class);
     // save current registration E-Mail flag
     $emailFlag = $options->getRegistrationEmailFlag();
     // disable all regsitration E-Mails
     $options->setRegistrationEmailFlag(0);
     // register user
     /* @var $userObject User */
     $userObject = $userService->register($data);
     if (!$userObject) {
         throw new \Exception(sprintf('Registration of user %s failed', $item->name));
     }
     // activate, set data, ...
     $userObject->setUsername($data['username']);
     $userObject->setEmail($data['email']);
     $userObject->setState(1);
     $userObject->addRoles(array($this->getReference('admin-role')));
     $manager->flush();
     // restore registration E-Mail flag
     $options->setRegistrationEmailFlag($emailFlag);
     $this->addReference('admin-user', $userObject);
 }
开发者ID:xelax90,项目名称:skeleton-module,代码行数:32,代码来源:LoadAdminUser.php


注:本文中的Doctrine\Common\Persistence\ObjectManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。