/** * add action - adds a post to the repository * * @param \Lobacher\Simpleblog\Domain\Model\Blog $blog * @param \Lobacher\Simpleblog\Domain\Model\Post $post */ public function addAction(\Lobacher\Simpleblog\Domain\Model\Blog $blog, \Lobacher\Simpleblog\Domain\Model\Post $post) { $post->setPostdate(new \DateTime()); //$this->postRepository->add($post); $post->setAuthor($this->objectManager->get('Lobacher\\Simpleblog\\Domain\\Repository\\AuthorRepository')->findOneByUid($GLOBALS['TSFE']->fe_user->user['uid'])); $blog->addPost($post); $this->objectManager->get('Lobacher\\Simpleblog\\Domain\\Repository\\BlogRepository')->update($blog); $this->redirect('show', 'Blog', NULL, array('blog' => $blog)); }
/** * add action - adds a post to the repository * * @param \Lobacher\Simpleblog\Domain\Model\Blog $blog * @param \Lobacher\Simpleblog\Domain\Model\Post $post * @return void */ public function addAction(Blog $blog, Post $post) { $post->setPostdate(new \DateTime()); if (($this->settings['blog']['users'] ?: '0') == '0') { $post->setAuthor($this->frontendUserRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid'])); } $blog->addPost($post); $this->objectManager->get('Lobacher\\Simpleblog\\Domain\\Repository\\BlogRepository')->update($blog); $this->redirect('show', 'Blog', NULL, array('blog' => $blog)); }
/** * @test */ public function setAuthorForAuthorSetsAuthor() { $authorFixture = new \Lobacher\Simpleblog\Domain\Model\Author(); $this->subject->setAuthor($authorFixture); $this->assertAttributeEquals($authorFixture, 'author', $this->subject); }