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


PHP ObjectManager::persist方法代码示例

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


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

示例1: load

 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();
 }
开发者ID:OscarAvR,项目名称:web_specialisatie_poc,代码行数:28,代码来源:LoadProjectPhotoData.php

示例2: cleanupTerms

 private function cleanupTerms(Treatment $treatment)
 {
     // find terms for this treatment
     $qb = $this->om->createQueryBuilder();
     $qb->select('t2')->from('TermBundle:Term', 't2')->innerJoin('t2.termDocuments', 'td', Join::WITH, 'td.type = :treatmentType')->setParameter('treatmentType', TermDocument::TYPE_TREATMENT)->where('td.documentId = :treatmentId')->setParameter('treatmentId', $treatment->getId());
     $terms = $qb->getQuery()->getResult();
     $this->output->writeln('Cleaning terms for treatment #' . $treatment->getId() . ' [' . $treatment->getName() . ']');
     if (\count($terms)) {
         $hasInternal = false;
         foreach ($terms as $term) {
             $this->output->write($this->indent() . $term->getName() . " [#{$term->getId()}]" . $this->indent());
             if (!$term->getInternal()) {
                 // if this has not been flagged as internal yet, flag it
                 $term->setInternal(\strtolower($term->getName()) == \strtolower($treatment->getName()));
             }
             if (!$hasInternal) {
                 $hasInternal = $term->getInternal();
             }
             $this->om->persist($term);
             $this->output->writeln('[OK]');
         }
         if (!$hasInternal) {
             $term = $this->createTermFromTreatment($treatment);
             $this->om->persist($term);
             $this->output->writeln($this->indent() . 'Added internal term');
         }
     } else {
         $this->output->write($this->indent() . "Found no terms: ");
         $term = $this->createTermFromTreatment($treatment);
         $this->om->persist($term);
         $this->output->writeln('[OK]');
     }
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:33,代码来源:CleanUpTreatmentTermsCommand.php

示例3: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $session = $manager->getPhpcrSession();
     $basepath = $this->container->getParameter('cmf_routing.dynamic.persistence.phpcr.route_basepath');
     NodeHelper::createPath($session, $basepath);
     $routeRoot = $manager->find(null, $basepath);
     $basepath = $this->container->getParameter('cmf_content.persistence.phpcr.content_basepath');
     NodeHelper::createPath($session, $basepath);
     $parent = $manager->find(null, $basepath);
     $repository = $this->container->get('sylius.repository.static_content');
     $routeRepository = $this->container->get('sylius.repository.route');
     // Terms of service.
     $route = $routeRepository->createNew();
     $route->setPosition($routeRoot, 'terms-of-service');
     $manager->persist($route);
     $content = $repository->createNew();
     $content->setTitle('Terms of Service');
     $content->setBody($this->faker->text(350));
     $content->addRoute($route);
     $content->setParent($parent);
     $content->setName('terms-of-service');
     $manager->persist($content);
     // Contact.
     $route = $routeRepository->createNew();
     $route->setPosition($routeRoot, 'about');
     $manager->persist($route);
     $content = $repository->createNew();
     $content->setTitle('About us');
     $content->setBody($this->faker->text(300));
     $content->addRoute($route);
     $content->setParent($parent);
     $content->setName('about-us');
     $manager->persist($content);
     $manager->flush();
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:38,代码来源:LoadPagesData.php

示例4: load

 public function load(ObjectManager $manager)
 {
     $utilisateur1 = new Utilisateurs();
     $utilisateur1->setUsername('Houda');
     $utilisateur1->setEmail('boucenna.nourelhouda@gmail.com');
     $utilisateur1->setEnabled(1);
     $utilisateur1->setPassword($this->container->get('security.encoder_factory')->getEncoder($utilisateur1)->encodePassword('doudou', $utilisateur1->getSalt()));
     $manager->persist($utilisateur1);
     $utilisateur2 = new Utilisateurs();
     $utilisateur2->setUsername('Bochra');
     $utilisateur2->setEmail('boucenna.bochra@gmail.com');
     $utilisateur2->setEnabled(1);
     $utilisateur2->setPassword($this->container->get('security.encoder_factory')->getEncoder($utilisateur2)->encodePassword('bchibcha', $utilisateur2->getSalt()));
     $manager->persist($utilisateur2);
     $utilisateur3 = new Utilisateurs();
     $utilisateur3->setUsername('Hanine');
     $utilisateur3->setEmail('boucenna.hanine@gmail.com');
     $utilisateur3->setEnabled(1);
     $utilisateur3->setPassword($this->container->get('security.encoder_factory')->getEncoder($utilisateur3)->encodePassword('hanouna', $utilisateur3->getSalt()));
     $manager->persist($utilisateur3);
     $utilisateur4 = new Utilisateurs();
     $utilisateur4->setUsername('Jamal');
     $utilisateur4->setEmail('boucenna.jamal@gmail.com');
     $utilisateur4->setEnabled(1);
     $utilisateur4->setPassword($this->container->get('security.encoder_factory')->getEncoder($utilisateur4)->encodePassword('jama', $utilisateur4->getSalt()));
     $manager->persist($utilisateur4);
     $manager->flush();
     $this->addReference('utilisateur1', $utilisateur1);
     $this->addReference('utilisateur2', $utilisateur2);
     $this->addReference('utilisateur3', $utilisateur3);
     $this->addReference('utilisateur4', $utilisateur4);
 }
开发者ID:Noor54,项目名称:SymfonyEcommerce,代码行数:32,代码来源:UtilisateursData.php

示例5: load

 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('user_admin@blog.com');
         $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('user_user@blog.com');
             $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();
 }
开发者ID:syrotchukandrew,项目名称:blog,代码行数:33,代码来源:LoadPostData.php

示例6: load

 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();
     }
 }
开发者ID:rvdavid,项目名称:siwapp-sf2,代码行数:29,代码来源:LoadItemData.php

示例7: process

 /**
  * 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;
 }
开发者ID:Maksold,项目名称:platform,代码行数:35,代码来源:EmailTemplateHandler.php

示例8: load

 /**
  * {@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();
 }
开发者ID:vikey89,项目名称:Sylius,代码行数:28,代码来源:LoadProductsData.php

示例9: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var User $userAdmin */
     $userAdmin = $this->getReference('user-admin');
     $product1 = new Product();
     $product1->setName('Upsell message');
     $product1->setCode("{{ 'twig' }}");
     $product1->setUser($userAdmin);
     $manager->persist($product1);
     $product2 = new Product();
     $product2->setName('me');
     $product2->setCode('sadsadsa');
     $product2->setCurrency('$');
     $manager->persist($product2);
     $product3 = new Product();
     $product3->setName('Close message');
     $product3->setCode("{{ 'twig' }}");
     $product3->setUser($userAdmin);
     $manager->persist($product3);
     $product4 = new Product();
     $product4->setName('продукт');
     $product4->setPrice(1000);
     $product4->setCurrency('$');
     $product4->setUser($userAdmin);
     $manager->persist($product4);
     $this->setReference('product-4', $product4);
     $product5 = new Product();
     $product5->setName('продукт');
     $product5->setPrice(1000);
     $product5->setCurrency('$');
     $product5->setUser($userAdmin);
     $manager->persist($product5);
     $this->setReference('product-5', $product5);
     $manager->flush();
 }
开发者ID:andreybolonin,项目名称:hmcrm,代码行数:38,代码来源:LoadProductData.php

示例10: createLayoutBlocks

 /**
  * @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();
 }
开发者ID:networking,项目名称:init-cms-sandbox,代码行数:34,代码来源:LoadLayoutBlocks.php

示例11: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $entity = new Office();
     $entity->setName('En Office');
     $entity->setAlias('en');
     $entity->setEmail('test@test.com');
     $entity->setProtocol('http');
     $entity->setHost($this->container->getParameter('hosts.root'));
     $entity->setRelatedUrl(null);
     $entity->setDefaultLanguage('en');
     $entity->setRecognizeLanguage('en');
     $entity->setAvailableLanguages(['en', 'ru']);
     $entity->setCurrencies(['EUR', 'USD']);
     $entity->setIncludeLangInUrl(false);
     $manager->persist($entity);
     $entity = new Office();
     $entity->setName('Ru Office');
     $entity->setAlias('ru');
     $entity->setEmail('test@test.com');
     $entity->setProtocol('http');
     $entity->setHost($this->container->getParameter('hosts.root'));
     $entity->setRelatedUrl(null);
     $entity->setDefaultLanguage('ru');
     $entity->setRecognizeLanguage('ru');
     $entity->setAvailableLanguages(['en', 'ru']);
     $entity->setCurrencies(['EUR', 'USD', 'RUB']);
     $manager->persist($entity);
     $manager->flush();
 }
开发者ID:octava,项目名称:cms,代码行数:32,代码来源:LoadOffices.php

示例12: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     if (!$this->isEnabled()) {
         return;
     }
     $tax = $this->randomizeSamples('tax', LoadTaxData::$samples);
     $currency = $this->randomizeSamples('currency', LoadCurrencyData::$samples);
     $factory = $this->container->get('shipping_method.factory');
     $fedEx = $factory->create();
     $fedEx->setCalculator('price_table');
     $fedEx->setTax($tax);
     $fedEx->setCurrency($currency);
     $fedEx->translate($this->container->getParameter('locale'))->setName('FedEx');
     $fedEx->mergeNewTranslations();
     $fedEx->setCosts($this->getShippingCostsCollection($fedEx));
     $manager->persist($fedEx);
     $ups = $factory->create();
     $ups->setCalculator('price_table');
     $ups->setTax($tax);
     $ups->setCurrency($currency);
     $ups->translate($this->container->getParameter('locale'))->setName('UPS');
     $ups->mergeNewTranslations();
     $ups->setCosts($this->getShippingCostsCollection($ups));
     $manager->persist($ups);
     $manager->flush();
     $this->setReference('shipping_method_fedex', $fedEx);
     $this->setReference('shipping_method_ups', $ups);
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:31,代码来源:LoadShippingMethodData.php

示例13: load

 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setEmail('superadmin@pixicms.com');
     $user->setUsername('user');
     $user->setPassword('user');
     $user->setUserRole($this->getReference('user-role'));
     $user->setName('User');
     $user->setIsActive(true);
     $admin = new User();
     $admin->setEmail('superadmin@pixicms.com');
     $admin->setUsername('admin');
     $admin->setPassword('admin');
     $admin->setUserRole($this->getReference('admin-role'));
     $admin->setName('Admin');
     $admin->setIsActive(true);
     $superAdmin = new User();
     $superAdmin->setEmail('superadmin@pixicms.com');
     $superAdmin->setUsername('superadmin');
     $superAdmin->setPassword('superadmin');
     $superAdmin->setUserRole($this->getReference('super-admin-role'));
     $superAdmin->setName('Super Admin');
     $superAdmin->setIsActive(true);
     $manager->persist($user);
     $manager->persist($admin);
     $manager->persist($superAdmin);
     $manager->flush();
     $this->addReference('user', $user);
     $this->addReference('admin', $admin);
     $this->addReference('super-admin', $superAdmin);
 }
开发者ID:sanjoy-k-mitra,项目名称:pixicms,代码行数:36,代码来源:LoadUserData.php

示例14: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $event = new event();
     $event->setJeu($this->getReference('LOL'));
     $event->setTitre("SK Gaming vs H2K");
     $event->setDescription("koaeoakzejoiaziejaoziejaoizeoaijzoei");
     $event->setEquipe1($this->getReference('M'));
     $event->setEquipe2($this->getReference('Gambit'));
     $event->setCoteteam1("1.245");
     $event->setCoteteam2("1.123");
     $event->setEquipegagnante($this->getReference('M'));
     $event->setJeu($this->getReference('LOL'));
     $event->setEtat("Terminé");
     $event->setDatefinpari(new \DateTime());
     $event1 = new event();
     $event1->setJeu($this->getReference('LOL'));
     $event1->setTitre("Fnatic Vs SKTT1");
     $event1->setDescription("koaeoakzejoiaziejaoziejaoizeoaijzoei");
     $event1->setEquipe1($this->getReference('M'));
     $event1->setEquipe2($this->getReference('Gambit'));
     $event1->setCoteteam1("1.245");
     $event1->setCoteteam2("1.123");
     $event1->setEquipegagnante($this->getReference('Gambit'));
     $event1->setJeu($this->getReference('LOL'));
     $event1->setEtat("Brouillon");
     $event1->setDatefinpari(new \DateTime());
     $manager->persist($event);
     $manager->persist($event1);
     $manager->flush();
     $this->addReference('M-vs-Gambit', $event);
     $this->addReference('Gambit-vs-M', $event1);
 }
开发者ID:nvkdesign,项目名称:Backup-incom,代码行数:35,代码来源:eventData.php

示例15: load

 /**
  * 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();
 }
开发者ID:scottstuff,项目名称:GCProtractorJS,代码行数:34,代码来源:LoadNotificationTypes.php


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