コード例 #1
0
 /**
  * A command to setup a blog
  *
  * With this command you can kickstart a new blog.
  *
  * @param string $blogTitle the name of the blog to create
  * @param boolean $reset set this flag to remove all previously created blogs and posts
  * @return void
  */
 public function setupCommand($blogTitle, $reset = FALSE)
 {
     if ($reset) {
         $this->blogRepository->removeAll();
         $this->postRepository->removeAll();
     }
     $blog = new Blog($blogTitle);
     $blog->setDescription('A blog about Foo, Bar and Baz.');
     $this->blogRepository->add($blog);
     $post = new Post();
     $post->setBlog($blog);
     $post->setAuthor('John Doe');
     $post->setSubject('Example Post');
     $post->setContent('Lorem ipsum dolor sit amet, consectetur adipisicing elit.' . chr(10) . 'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.');
     $this->postRepository->add($post);
     $this->outputLine('Successfully created a blog "%s"', [$blogTitle]);
 }
コード例 #2
0
ファイル: PostRepository.php プロジェクト: neos/Acme.Blog
 /**
  * Finds the post next to the given post
  *
  * @param Post $post The reference post
  * @return Post
  */
 public function findNext(Post $post)
 {
     $query = $this->createQuery();
     return $query->matching($query->logicalAnd([$query->equals('blog', $post->getBlog()), $query->greaterThan('date', $post->getDate())]))->setOrderings(array('date' => QueryInterface::ORDER_ASCENDING))->execute()->getFirst();
 }