本文整理汇总了PHP中AppBundle\Entity\Post::setState方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::setState方法的具体用法?PHP Post::setState怎么用?PHP Post::setState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\Post
的用法示例。
在下文中一共展示了Post::setState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadPosts
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('anna_admin@symfony.com');
$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('john_user@symfony.com');
$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: loadPosts
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('a.martynenko@levi9.com');
$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('d.kiprushev@levi9.com');
$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) ? 'a.martynenko@levi9.com' : 'd.kiprushev@levi9.com');
$vote->setPost($post);
$vote->setVote(rand(0, 1));
}
$manager->persist($post);
$category->addPost($post);
}
$manager->flush();
}
示例3: changePostState
/**
* @param Request $request
* @param Post $post
*/
private function changePostState(Request $request, Post $post)
{
if ($request->request->has('review')) {
$post->setState(Post::STATUS_REVIEW);
} elseif ($request->request->has('publish') && $this->isGranted('ROLE_ADMIN')) {
$post->setState(Post::STATUS_VOTING);
}
}