Pergunta

I am doing FLOW3 definitive guide : Part3: Controller

My blog supposed to be created and saved in the database but it is not. Configuration of the databse is correct (FLOW3 has created tables and doctrine migrates/updates successfuly), code looks correct (copied from FLOW3 definitve guide GIT repo).

Does anyone have similar problem?

Here is my indexAction from SetupController which supposed to create blog in the 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';
    }

I will appreciate any help and will provide more info if I am not clear enough.

Thx in advance

Foi útil?

Solução

TYPO3 FLOW doesn't persist changes for Safe Requests (like HTTP GET) anymore since 2.0.

That means if you want to persist changes in a GET-Request, you have to call persistenceManager->persistAll() yourself.

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();
        }
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top