private function loadPosts(ObjectManager $manager) { foreach (range(1, 10) as $i) { $post = new Post(); $post->setTitle($this->getRandomPostTitle()); $post->setSummary($this->getRandomPostSummary()); $post->setSlug($this->container->get('slugger')->slugify($post->getTitle())); $post->setContent($this->getPostContent()); $post->setAuthorEmail('*****@*****.**'); $post->setPublishedAt(new \DateTime('now - ' . $i . 'days')); foreach (range(1, 5) as $j) { $comment = new Comment(); $comment->setAuthorEmail('*****@*****.**'); $comment->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds')); $comment->setContent($this->getRandomCommentContent()); $comment->setPost($post); $manager->persist($comment); $post->addComment($comment); } $manager->persist($post); } $manager->flush(); }
/** * {@inheritDoc} */ public function setPublishedAt($publishedAt) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPublishedAt', array($publishedAt)); return parent::setPublishedAt($publishedAt); }