Пример #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
 /**
  * @param Blog $blog
  * @return void
  */
 public function setBlog(Blog $blog)
 {
     $this->blog = $blog;
     $this->blog->addPost($this);
 }