setPublishedAt() публичный метод

public setPublishedAt ( DateTime $publishedAt )
$publishedAt DateTime
Пример #1
0
 private function loadPosts(ObjectManager $manager)
 {
     foreach (range(1, 30) as $i) {
         $post = new Post();
         $post->setTitle('Sed ut perspiciatis unde');
         $post->setAlias('Sed ut perspiciatis unde');
         $post->setIntrotext('Sed ut perspicantium, tocto beatae vitae dicta sunt explicabo. ');
         $post->setSlug($this->container->get('slugger')->slugify($post->getTitle()));
         $post->setBody('Sed ut is iste uasi architecto beatae vitae dicta sunt explicabo. ');
         $post->setAuthorEmail('*****@*****.**');
         $post->setPublishedAt(new \DateTime('now - ' . $i . 'days'));
         $post->setState(1);
         $post->setImages('test.jpg');
         foreach (range(1, 5) as $j) {
             $comment = new Comment();
             $comment->setAuthorEmail('*****@*****.**');
             $comment->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds'));
             $comment->setContent('Sed ut perspiciatis undedasdadasd');
             $comment->setPost($post);
             $manager->persist($comment);
             $post->addComment($comment);
         }
         $manager->persist($post);
     }
     $manager->flush();
 }
Пример #2
0
 private function loadPosts(ObjectManager $manager)
 {
     $category = new Category();
     $category->setName('Improvements');
     foreach (range(1, 5) 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'));
         $post->setState($this->getRandomState());
         $post->setCategory($category);
         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);
         }
         if (rand(0, 1)) {
             $vote = new Vote();
             $vote->setAuthorEmail(rand(0, 1) ? '*****@*****.**' : '*****@*****.**');
             $vote->setPost($post);
             $vote->setVote(rand(0, 1));
         }
         $manager->persist($post);
         $category->addPost($post);
     }
     $manager->flush();
 }
Пример #3
0
 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();
 }