public function load(ObjectManager $manager)
 {
     $post = new Post();
     $post->setTitle('Post title with Tag 1');
     $post->setContent('My post content!');
     $post->setIsPublished(false);
     $post->setCreatedAt(new \DateTime('2016-01-01 12:00:00'));
     if ($this->hasReference('tag1')) {
         $post->addTag($this->getReference('tag1'));
         $post->addTag($this->getReference('tag2'));
     }
     $manager->persist($post);
     $manager->flush();
 }
 protected function createNewPost($title, $content, $createdAt, $tag = null)
 {
     $post = new Post();
     $post->setTitle($title);
     $post->setContent($content);
     $post->setCreatedAt($createdAt);
     if ($tag && $this->hasReference($tag)) {
         $post->addTag($this->getReference($tag));
     }
     $this->manager->persist($post);
     $this->manager->flush();
 }