[Flow] The Definitive Guide Blog Data Not Sent To The Database

Steffen Wickham steffen at gaming-inc.de
Mon Mar 24 20:41:57 CET 2014


Hello again Richard! ;)

Yeah the definitive guide is a bit outdated at this point. There was a
breaking change from Flow 1.X to 2.0 where safe requests were introduced
to Flow. All HTTP GET requests to any Controller of Flow are meant to be
save requests, so no modified (or created) data will be saved. To save
the created data you have to do a POST request to your function or just
add "$this->persistenceManager->persistAll();" at the lower bottom of
your method, just before your return statement and perform another call
to the Setup Controller.

But be warned: This method is very unsafe and should be only used for
testing!

Greetings
Steffen



Am 24.03.2014 19:09, schrieb Richard Benson:
> Hello!
>
> All works well until the setup Controller:
> docs.typo3.org/flow/TYPO3FlowDocumentation/2.2/TheDefinitiveGuide/PartII/Controller.html
>
> When I call dev.tutorial.local/typo3.blog/setup/index I get
> "Successfully created a blog" as expected but the database remains
> empty. No error is thrown and debugging.
> I have a database connection as all the
> "flow_doctrine_migrationstatus" etc is in my database so I know there
> is a connection
> I have run ./flow doctrine:update as stated but when I view
>
> dev.tutorial.local/typo3.blog/post
>
> There are no posts.
>
> So with no errors and no posts being sent to the database where to look?
>
> the SetupController
>
> <?php
> namespace TYPO3\Blog\Controller;
>
> /*                                                                       
> *
> * This script belongs to the TYPO3 Flow package
> "TYPO3.Blog".            *
> *                                                                       
> *
> *                                                                       
> */
>
> use TYPO3\Flow\Annotations as Flow;
>
> class SetupController extends
> \TYPO3\Flow\Mvc\Controller\ActionController {
>         /**
>         * @Flow\Inject
>         * @var \TYPO3\Blog\Domain\Repository\BlogRepository
>         */
>     protected $blogRepository;
>
>     /**
>    * @Flow\Inject
>    * @var \TYPO3\Blog\Domain\Repository\PostRepository
>    */
>     protected $postRepository;
>
>     /**
>         * 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 B2B');
>        $this->blogRepository->add($blog);
>
>        $post = new \TYPO3\Blog\Domain\Model\Post();
>        $post->setAuthor('Richard Benson');
>        $post->setTitle('Start up Posts');
>        $post->setContent('This is the Body Text for the blog posts
> 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);
>
>        $blog->addPost($post);
>
>        return 'Successfully created a blog';
>     }
>
> }
>
> ?>
>
>
> Kind Regards
>
> Richard
>
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow



More information about the Flow mailing list