/** * @test */ public function addPostToObjectStorageHoldingPosts() { $post = new \Lobacher\Simpleblog\Domain\Model\Post(); $postsObjectStorageMock = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', array('attach'), array(), '', FALSE); $postsObjectStorageMock->expects($this->once())->method('attach')->with($this->equalTo($post)); $this->inject($this->subject, 'posts', $postsObjectStorageMock); $this->subject->addPost($post); }
/** * 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)); }