當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectManager::merge方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Persistence\ObjectManager::merge方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectManager::merge方法的具體用法?PHP ObjectManager::merge怎麽用?PHP ObjectManager::merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Persistence\ObjectManager的用法示例。


在下文中一共展示了ObjectManager::merge方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: load

 public function load(ObjectManager $em)
 {
     $files = Finder::create()->name('*.*')->in(__DIR__ . '/../data/files');
     $manager = $this->container->get('sonata.media.manager.media');
     $medias = [];
     foreach ($files as $pos => $file) {
         $media = new Media();
         $media->setBinaryContent($file);
         $media->setEnabled(true);
         $manager->save($media, 'gallery', 'sonata.media.provider.image');
         $medias[] = $media;
     }
     for ($i = 1; $i < 2; $i++) {
         $post = new Photo();
         $post->setCategory($em->merge($this->getReference("PhotoCategory-1")));
         $post->setTitle("testowe " . $i);
         $post->setImage($medias[0]);
         $post2 = new Photo();
         $post2->setCategory($em->merge($this->getReference("PhotoCategory-" . rand(1, 6))));
         $post2->setTitle("testowe " . $i);
         $post2->setImage($medias[1]);
         $em->persist($post2);
         $em->persist($post);
         $em->flush();
         $this->addReference('Photo-' . $i, $post);
         $this->addReference('Photo-' . ($i - 1), $post2);
     }
 }
開發者ID:Aldor007,項目名稱:mkaciuba.pl,代碼行數:28,代碼來源:LoadPhotoData.php

示例2: load

 /**
  * @inheritdoc
  */
 public function load(ObjectManager $manager)
 {
     $adminPerm = $manager->merge($this->getReference('permission-ROLE_ADMIN'));
     $projectCreatePerm = $manager->merge($this->getReference('permission-ROLE_PROJECT_CREATE'));
     $projectReadPerm = $manager->merge($this->getReference('permission-PROJECT_READ'));
     $projectAdminPerm = $manager->merge($this->getReference('permission-PROJECT_ADMIN'));
     $admin = new Role('Administrator', 'admin', 'Master of the application', true);
     $admin->addPermission($adminPerm);
     $admin->addPermission($projectCreatePerm);
     $manager->persist($admin);
     $this->setReference('role-admin', $admin);
     $projectCreator = new Role('Project creator', 'project-creator', 'Capable to create projects', true);
     $projectCreator->addPermission($projectCreatePerm);
     $manager->persist($projectCreator);
     $this->setReference('role-project-creator', $projectCreator);
     $leadDev = new Role('Lead developer', 'lead-dev', 'Merge leader', false);
     $leadDev->addPermission($projectReadPerm);
     $leadDev->addPermission($projectAdminPerm);
     $manager->persist($leadDev);
     $this->setReference('role-lead-developer', $leadDev);
     $developer = new Role('Developer', 'dev', 'No admin access to repositories', false);
     $developer->addPermission($projectCreatePerm);
     $developer->addPermission($projectReadPerm);
     $manager->persist($developer);
     $this->setReference('role-developer', $developer);
     $visitor = new Role('Visitor', 'visitor', 'Read-only viewers', false);
     $visitor->addPermission($projectReadPerm);
     $manager->persist($visitor);
     $this->setReference('role-visitor', $visitor);
     $manager->flush();
 }
開發者ID:phecho,項目名稱:gitonomy,代碼行數:34,代碼來源:LoadRoleData.php

示例3: load

 public function load(ObjectManager $em)
 {
     $comment_blog = new Comment();
     $comment_blog->setPost($em->merge($this->getReference('post-blog')));
     $comment_blog->setUsername('admin');
     $comment_blog->setAuthorEmail('admin@symfony.com');
     $comment_blog->setWebsite('www.demo.pl');
     $comment_blog->setContent('YouTube has become the standard way for delivering high quality video on the web.');
     //$comment_blog->setIsApproved(0);
     $comment_shop = new Comment();
     $comment_shop->setPost($em->merge($this->getReference('post-shop')));
     $comment_shop->setUsername('journalist');
     $comment_shop->setAuthorEmail('journalist@symfony.com');
     $comment_shop->setContent('Bootstrap is the most widely used frontend framework right now.');
     $em->persist($comment_blog);
     $em->persist($comment_shop);
     foreach (range(0, 60) as $i) {
         $comment = new Comment();
         $comment->setPost($em->merge($this->getReference('post-post' . rand(0, 30))));
         //mamy 30 postów dlatego rand(0, 30)
         $surfer = $this->getRandomSurfer();
         $comment->setUsername($surfer['username']);
         $comment->setAuthorEmail($surfer['author_email']);
         $comment->setWebsite($this->getRandomWebsite());
         $comment->setContent($this->getRandomContent());
         $comment->setIsApproved(rand(0, 1) == 0 ? 0 : 1);
         $comment->setPublishedAt(new \DateTime('now - ' . rand(1, 4) . 'days'));
         $em->persist($comment);
     }
     $em->flush();
     $this->addReference('comment-blog', $comment_blog);
     $this->addReference('comment-shop', $comment_shop);
 }
開發者ID:sidczak-tti,項目名稱:blog2.8,代碼行數:33,代碼來源:LoadCommentData.php

示例4: load

 public function load(ObjectManager $manager)
 {
     $comment = new Comment();
     $comment->setUser('Olik1');
     $comment->setComment('tram param1');
     $comment->setBlog($manager->merge($this->getReference('blog-1')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Olik2');
     $comment->setComment('tram param');
     $comment->setBlog($manager->merge($this->getReference('blog-1')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Olik3');
     $comment->setComment('tram param2');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Olik4');
     $comment->setComment('tram param3');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Olik5');
     $comment->setComment('tram param4');
     $comment->setBlog($manager->merge($this->getReference('blog-1')));
     $manager->persist($comment);
     $manager->flush();
 }
開發者ID:flaberd,項目名稱:cook,代碼行數:29,代碼來源:CommentFixtures.php

示例5: load

 /**
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var Event $eventZFDays, $eventPHPDay */
     $eventZFDays = $manager->merge($this->getReference('event-zfday'));
     $eventPHPDay = $manager->merge($this->getReference('event-phpday'));
     // Promo code 1
     $promoCode = new PromoCode();
     $promoCode->setTitle('Promo code for ZFDays')->setCode('Promo code for ZFDays')->setEvent($eventZFDays);
     $manager->persist($promoCode);
     $this->addReference('promoCode-1', $promoCode);
     // Promo code 2
     $promoCode = new PromoCode();
     $promoCode->setTitle('Promo code for ZFDays 5%')->setCode('Promo code for ZFDays 5%')->setDiscountAmount(5)->setEvent($eventZFDays);
     $manager->persist($promoCode);
     $this->addReference('promoCode-2', $promoCode);
     // Promo code 3
     $promoCode = new PromoCode();
     $promoCode->setTitle('Promo code for ZFDays overdue')->setCode('Promo code for ZFDays overdue')->setEvent($eventZFDays)->setEndDate(new \DateTime('-11 Days'));
     $manager->persist($promoCode);
     $this->addReference('promoCode-3', $promoCode);
     // Promo code 4
     $promoCode = new PromoCode();
     $promoCode->setTitle('Promo code for PHPDay')->setCode('Promo code for PHPDay')->setEvent($eventPHPDay);
     $manager->persist($promoCode);
     $this->addReference('promoCode-4', $promoCode);
     $manager->flush();
 }
開發者ID:bolotyuh,項目名稱:fwdays,代碼行數:30,代碼來源:LoadPromoCodeData.php

示例6: load

 /**
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var User $userDefault */
     $userDefault = $manager->merge($this->getReference('user-default'));
     $payment = new Payment();
     $payment->setUser($userDefault);
     $payment->setAmount(0);
     $payment->setStatus(Payment::STATUS_PAID);
     $manager->persist($payment);
     $this->addReference('payment', $payment);
     $payment = new Payment();
     $payment->setUser($userDefault);
     $payment->setAmount(0);
     $payment->setStatus(Payment::STATUS_PENDING);
     $manager->persist($payment);
     $this->addReference('pending', $payment);
     /** @var User $userDefault2 */
     $userDefault2 = $manager->merge($this->getReference('user-default2'));
     $payment = new Payment();
     $payment->setUser($userDefault2);
     $payment->setAmount(0);
     $payment->setStatus(Payment::STATUS_PAID);
     $manager->persist($payment);
     $this->addReference('payment2', $payment);
     $payment = new Payment();
     $payment->setUser($userDefault2);
     $payment->setAmount(0);
     $payment->setStatus(Payment::STATUS_PENDING);
     $manager->persist($payment);
     $this->addReference('pending2', $payment);
     $manager->flush();
 }
開發者ID:jekakm,項目名稱:fwdays,代碼行數:35,代碼來源:LoadPaymentData.php

示例7: load

 public function load(ObjectManager $em)
 {
     $img_blog = new Image();
     $img_blog->setPost($em->merge($this->getReference('post-blog')));
     $img_blog->setImage('blog.jpg');
     $img_shop = new Image();
     $img_shop->setPost($em->merge($this->getReference('post-shop')));
     $img_shop->setImage('shop.jpg');
     $em->persist($img_blog);
     $em->persist($img_shop);
     foreach (range(0, 30) as $i) {
         //mamy 30 postów dlatego rand(0, 30)
         $img = new Image();
         $post = $this->getReference('post-post' . $i);
         $img->setPost($em->merge($post));
         switch ($post->getCategory()) {
             case $this->getReference('category-blog'):
                 $img->setImage('blog.jpg');
                 break;
             case $this->getReference('category-shop'):
                 $img->setImage('shop.jpg');
                 break;
             default:
                 $img->setImage(null);
         }
         $em->persist($img);
     }
     $em->flush();
 }
開發者ID:sidczak-tti,項目名稱:blog2.8,代碼行數:29,代碼來源:LoadImageData.php

示例8: load

 /**
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     // Get references for event fixtures
     $eventZFDay = $manager->merge($this->getReference('event-zfday'));
     $eventPHPDay = $manager->merge($this->getReference('event-phpday'));
     $speaker = new Speaker();
     $speaker->setName('Андрей Шкодяк');
     $speaker->setEmail('a_s@test.com');
     $speaker->setCompany('Stfalcon');
     $speaker->setAbout('About Andrew');
     $speaker->setSlug('andrew-shkodyak');
     $speaker->setFile($this->_generateUploadedFile('andrew.png'));
     $speaker->setEvents(array($eventZFDay, $eventPHPDay));
     $manager->persist($speaker);
     $this->addReference('speaker-shkodyak', $speaker);
     $speaker = new Speaker();
     $speaker->setName('Валерий Рабиевский');
     $speaker->setEmail('v_r@test.com');
     $speaker->setCompany('Stfalcon');
     $speaker->setAbout('About Valeriy');
     $speaker->setSlug('valeriy-rabievskiy');
     $speaker->setFile($this->_generateUploadedFile('valeriy.png'));
     $speaker->setEvents(array($eventZFDay, $eventPHPDay));
     $manager->persist($speaker);
     $this->addReference('speaker-rabievskiy', $speaker);
     $manager->flush();
 }
開發者ID:bolotyuh,項目名稱:fwdays,代碼行數:30,代碼來源:LoadSpeakerData.php

示例9: load

 public function load(ObjectManager $manager)
 {
     $comment1 = new Comment();
     $comment1->setTitle('Sample Comment 1');
     $comment1->setUsername('blogger1');
     $comment1->setComment('To make a long story short. You can\'t go wrong by choosing Symfony! And no one has ever been fired for using Symfony.');
     $comment1->setApproved(true);
     $comment1->setCreated(new \DateTime());
     $comment1->setCommentType('Blog');
     $comment1->setBlogPost($manager->merge($this->getReference('blog1')));
     $manager->persist($comment1);
     $comment2 = new Comment();
     $comment2->setTitle('Sample Comment 2');
     $comment2->setUsername('blogger2');
     $comment2->setComment('To make a long story short. You can\'t go wrong by choosing Symfony! And no one has ever been fired for using Symfony 2.');
     $comment2->setApproved(true);
     $comment2->setCreated(new \DateTime());
     $comment2->setCommentType('Blog');
     $comment2->setBlogPost($manager->merge($this->getReference('blog1')));
     $manager->persist($comment2);
     $comment3 = new Comment();
     $comment3->setTitle('Sample Comment 3');
     $comment3->setUsername('blogger3');
     $comment3->setComment('To make a long story short. You can\'t go wrong by choosing Symfony! And no one has ever been fired for using Symfony 3.');
     $comment3->setApproved(true);
     $comment3->setCreated(new \DateTime());
     $comment3->setCommentType('Blog');
     $comment3->setBlogPost($manager->merge($this->getReference('blog1')));
     $manager->persist($comment3);
     $manager->flush();
 }
開發者ID:elom5000,項目名稱:BardisCMS,代碼行數:31,代碼來源:CommentFixtures.php

示例10: load

 /**
  * Create and load posts fixtures to database
  *
  * @param ObjectManager $manager Entity manager object
  */
 public function load(ObjectManager $manager)
 {
     $adminUser = $this->getReference('user-admin');
     $secondUser = $this->getReference('user-second');
     $symfonyTag = $this->getReference('tag-symfony2');
     $doctrine2Tag = $this->getReference('tag-doctrine2');
     // posts
     $postFirst = new Post();
     $postFirst->setTitle('My first post');
     $postFirst->setSlug('my-first-post');
     $postFirst->setText('In work we use Symfony2.<!--more-->And text after cut');
     $postFirst->addTag($symfonyTag);
     $postFirst->addTag($doctrine2Tag);
     $postFirst->setAuthor($adminUser);
     $postFirst->setPublished(true);
     $manager->persist($postFirst);
     $manager->merge($symfonyTag);
     $manager->merge($doctrine2Tag);
     $postAboutPhp = new Post();
     $postAboutPhp->setTitle('Post about php');
     $postAboutPhp->setSlug('post-about-php');
     $postAboutPhp->setText('The PHP development team would like to announce the immediate availability of PHP 5.3.6.');
     $postAboutPhp->addTag($symfonyTag);
     $postAboutPhp->addTag($doctrine2Tag);
     $postAboutPhp->setAuthor($secondUser);
     $postAboutPhp->setPublished(true);
     $manager->persist($postAboutPhp);
     $manager->merge($symfonyTag);
     $manager->merge($doctrine2Tag);
     $manager->flush();
     $this->addReference('post-first', $postFirst);
     $this->addReference('post-about-php', $postAboutPhp);
 }
開發者ID:alienpham,項目名稱:portfolio,代碼行數:38,代碼來源:LoadPostData.php

示例11: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $em)
 {
     $entity = new Projet();
     $entity->setNomprojet('Chaudière à bois pour l\'école');
     $entity->setDescription('chaudière à bois déchiqueté de 100 Kw consommation de 70 T annuelles de bois bocager issus de l\'élagage des haies');
     $entity->setDaterealisation(new \DateTime('2013-01-01'));
     $entity->setDuree('3 mois');
     $entity->setGains('des économies importantes grâce au chauffage de 5 bâtiments soit 3 000 m2');
     $entity->setCout('20 000');
     $entity->setFinancement('departement:3;');
     $file = new File(__DIR__ . '/../Data/chauffage.jpg');
     $destFile = __DIR__ . '/../Data/tmp-chauffagebois.jpg';
     copy($file, $destFile);
     $entity->file = new File($destFile);
     $entity->setUser($em->merge($this->getReference('user-olivier')));
     $em->persist($entity);
     $entity = new Projet();
     $entity->setNomprojet('Chaudière à bois pour l\'école du village et un local avec un conteneur préfabriqué');
     $entity->setDescription('chaudière à bois  de bois bocager issus de l\'élagage des haies ');
     $entity->setDaterealisation(new \DateTime('2014-03-01'));
     $entity->setDuree('3 mois');
     $entity->setGains('des économies importantes grâce au chauffage de 520 m2 de locaux ');
     $entity->setCout('53 000');
     $entity->setFinancement('departement:3;');
     $file = new File(__DIR__ . '/../Data/chaudiere.png');
     $destFile = __DIR__ . '/../Data/tmp-chaudierebois.png';
     copy($file, $destFile);
     $entity->file = new File($destFile);
     $entity->setUser($em->merge($this->getReference('user-gilbert')));
     $em->persist($entity);
     $em->flush();
 }
開發者ID:WildCodeSchool,項目名稱:projet-wiki_des_maires,代碼行數:35,代碼來源:LoadProjetData.php

示例12: load

 public function load(ObjectManager $em)
 {
     $design = new Tag();
     $design->setName('Grafika');
     $design->setCount(1);
     $design->addPost($em->merge($this->getReference("Post-1")));
     $programming = new Tag();
     $programming->setName('Programowanie');
     $programming->setCount(1);
     $programming->addPost($em->merge($this->getReference("Post-1")));
     $linux = new Tag();
     $linux->setName('Linux');
     $linux->setCount(1);
     $linux->addPost($em->merge($this->getReference("Post-1")));
     $cubie = new Tag();
     $cubie->setName('Cubieboard');
     $cubie->setCount(1);
     $cubie->addPost($em->merge($this->getReference("Post-2")));
     $em->persist($design);
     $em->persist($programming);
     $em->persist($linux);
     $em->persist($cubie);
     $em->flush();
     $this->addReference('Tag-design', $design);
     $this->addReference('Tag-programming', $programming);
     $this->addReference('Tag-linux', $linux);
     $this->addReference('Tag-cubieboard', $cubie);
 }
開發者ID:Aldor007,項目名稱:mkaciuba.pl,代碼行數:28,代碼來源:LoadTagData.php

示例13: load

 public function load(ObjectManager $em)
 {
     $files = Finder::create()->name('*.JPG')->in(__DIR__ . '/../data/files');
     $manager = $this->container->get('sonata.media.manager.media');
     foreach ($files as $pos => $file) {
         $media = new Media();
         $media->setBinaryContent($file);
         $media->setEnabled(true);
         $manager->save($media, 'portfolio', 'sonata.media.provider.image');
     }
     $pro = new Project();
     $pro->setTechnology($em->merge($this->getReference("Technology-web")));
     $pro->setName("Symfony2 Portfolio");
     $pro->setMedia($media);
     $pro->setDescription('aaa');
     $pro->setRawContent("\n\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
     $pro->setContent("\n\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
     $pro->setUrl("no");
     $pro->setDate(new \DateTime());
     $pro2 = new Project();
     $pro2->setTechnology($em->merge($this->getReference("Technology-asm")));
     $pro2->setName("Symfony2 Portfolio test");
     $pro2->setMedia($media);
     $pro2->setDescription('asfasfasf');
     $pro2->setRawContent("\nsdf\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
     $pro2->setContent("\nsdf\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
     $pro2->setUrl("no");
     $pro2->setDate(new \DateTime());
     $em->persist($pro2);
     $em->persist($pro);
     $em->flush();
 }
開發者ID:Aldor007,項目名稱:mkaciuba.pl,代碼行數:32,代碼來源:LoadProjectData.php

示例14: load

 public function load(ObjectManager $em)
 {
     $first = new Expense();
     $first->setName('Beer with friends');
     $first->setSum(200);
     $first->setDescription('It was very good!');
     $first->setExpenseItem($em->merge($this->getReference('expense-item-beer')));
     $second = new Expense();
     $second->setName('Petrol 10 l');
     $second->setSum(180);
     $second->setDescription('OKKO');
     $second->setExpenseItem($em->merge($this->getReference('expense-item-petrol')));
     $third = new Expense();
     $third->setName('Mobil Super 2000 1 l');
     $third->setSum(150);
     $third->setDescription('Wrong type of oil');
     $third->setExpenseItem($em->merge($this->getReference('expense-item-motor-oil')));
     $fourth = new Expense();
     $fourth->setName('New jeans');
     $fourth->setSum('500');
     $fourth->setExpenseItem($em->merge($this->getReference('expense-item-jeans')));
     $em->persist($first);
     $em->persist($second);
     $em->persist($third);
     $em->persist($fourth);
     $em->flush();
 }
開發者ID:abc100,項目名稱:finance,代碼行數:27,代碼來源:LoadExpenseData.php

示例15: load

 public function load(ObjectManager $em)
 {
     $product_transaction1 = new ProductTransaction();
     $product_transaction1->setProduct($em->merge($this->getReference('product-asus_cp6130')));
     $product_transaction1->setTransaction($em->merge($this->getReference('transaction-transaction1')));
     $product_transaction1->setQuantity(1);
     $product_transaction2 = new ProductTransaction();
     $product_transaction2->setProduct($em->merge($this->getReference('product-asus_cp6130')));
     $product_transaction2->setTransaction($em->merge($this->getReference('transaction-transaction2')));
     $product_transaction2->setQuantity(2);
     $product_transaction3 = new ProductTransaction();
     $product_transaction3->setProduct($em->merge($this->getReference('product-samsung_series3')));
     $product_transaction3->setTransaction($em->merge($this->getReference('transaction-transaction2')));
     $product_transaction3->setQuantity(2);
     $product_transaction4 = new ProductTransaction();
     $product_transaction4->setProduct($em->merge($this->getReference('product-asus_cp6130')));
     $product_transaction4->setTransaction($em->merge($this->getReference('transaction-transaction3')));
     $product_transaction4->setQuantity(2);
     $product_transaction5 = new ProductTransaction();
     $product_transaction5->setProduct($em->merge($this->getReference('product-samsung_series3')));
     $product_transaction5->setTransaction($em->merge($this->getReference('transaction-transaction3')));
     $product_transaction5->setQuantity(1);
     $em->persist($product_transaction1);
     $em->persist($product_transaction2);
     $em->persist($product_transaction3);
     $em->persist($product_transaction4);
     $em->persist($product_transaction5);
     $em->flush();
 }
開發者ID:sidczak-tti,項目名稱:shop,代碼行數:29,代碼來源:LoadProductTransactionData.php


注:本文中的Doctrine\Common\Persistence\ObjectManager::merge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。