AppBundle\Entity\Comment::setPublishedAt PHP Method

setPublishedAt() public method

public setPublishedAt ( DateTime $publishedAt )
$publishedAt DateTime
    public function setPublishedAt(\DateTime $publishedAt)
    {
        $this->publishedAt = $publishedAt;
    }

Usage Example

示例#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();
 }
All Usage Examples Of AppBundle\Entity\Comment::setPublishedAt