/**
  * Create and load posts fixtures to database
  *
  * @param Doctrine\ORM\EntityManager $manager Entity manager object
  *
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     for ($i = 1; $i <= 12; $i++) {
         $post = new Post();
         $post->setTitle('Post for paginator #' . $i);
         $post->setSlug('post-for-paginator-' . $i);
         $post->setText('Generally this bundle is based on Knp Pager component. This component introduces a different way for pagination handling. You can read more about the internal logic on the given documentation link.' . $i);
         $post->setTags(array($manager->merge($this->getReference('tag-php'))));
         $manager->persist($post);
     }
     $manager->flush();
 }
Example #2
0
 /**
  * Create and load posts fixtures to database
  *
  * @param Doctrine\ORM\EntityManager $manager Entity manager object
  *
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     // 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->setTags(array($manager->merge($this->getReference('tag-symfony2')), $manager->merge($this->getReference('tag-doctrine2'))));
     $manager->persist($postfirst);
     $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->setTags(array($manager->merge($this->getReference('tag-symfony2')), $manager->merge($this->getReference('tag-php'))));
     $manager->persist($postaboutphp);
     $manager->flush();
     $this->addReference('post-first', $postfirst);
     $this->addReference('post-about-php', $postaboutphp);
 }