2013-08-21 35 views
1

我做FLOW3權威指南:Part3: ControllerFLOW3權威指南:無法保存博客數據庫

我的博客應該被創建並保存在數據庫中,但事實並非如此。數據庫的配置是正確的(FLOW3已經創建了表和學說成功遷移/更新),代碼看起來是正確的(從FLOW3定義指南GIT repo中複製)。

有沒有人有類似的問題?

這裏是SetupController我的indexAction它應該在DATABSE創建博客:

/** 
    * Sets up a fresh blog and creates a sample post. 
    * 
    * @return void 
    */ 
    public function indexAction() { 
     $this->blogRepository->removeAll(); 
     $this->postRepository->removeAll(); 

     $blog = new \TYPO3\Blog\Domain\Model\Blog(); 
     $blog->setTitle('My Blog'); 
     $blog->setDescription('A blog about Foo, Bar and Baz.'); 
     $this->blogRepository->add($blog); 

     $post = new \TYPO3\Blog\Domain\Model\Post(); 
     $post->setAuthor('John Doe'); 
     $post->setTitle('Example Post'); 
     $post->setContent('Lorem ipsum dolor sit amet, consectetur adipisicing elit, 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); 

     return $blog->addPost($post) == true ? 'success' : 'error'; 
    } 

我會感謝所有幫助,並會提供更多的信息,如果我不夠清晰。提前

THX

回答

3

TYPO3流不會持續Safe Requests (like HTTP GET)改變了自2.0。

這意味着如果您想在GET-Request中保留更改,您必須自己撥打persistenceManager->persistAll()

class SetupController extends \TYPO3\Flow\Mvc\Controller\ActionController { 


     /** 
     * @Flow\Inject 
     * @var \TYPO3\Flow\Persistence\PersistenceManagerInterface 
     */ 
     protected $persistenceManager; 

     //.... 

     public function indexAction() { 
       //.... your code 
       $this->persistenceManager->persistAll(); 
     } 
}