[Flow] Problem to follow the "Definitive Guide"

Steffen Wickham steffen at gaming-inc.de
Sun Apr 26 17:59:49 CEST 2015


Hello Jonas,

The Definitive Guide is a bit outdated. As of Flow 2.0(?) there is a new 
security feature which allows to safe data if the request method is not 
GET nor HEAD. You have to add a 
"$this->persistenceManager->persistAll();" before returning any value or 
checking if the data had been saved. A more secure way will be to add 
the following lines instead, so only your designated object will be 
persisted:

$this->persistenceManager->whitelistObject($blog);
$this->persistenceManager->persistAll(TRUE);


Hope it will work. :)

All the best,
Steffen



Am 26.04.2015 um 17:37 schrieb Jonas Schmidt:
> Hello,
>
> I tried to follow the "The Definitve Guide" to do my fist steps with 
> flow. I came to Part II Chapter "Controller / Basic Post Controller".
>
> After I run dev.tutorial.local/typo3.blog/post I got the following 
> PHP-Error:
>
> PHP Fatal error:  Call to a member function getTitle() on a non-object 
> in 
> /root/Flow3/tutorial/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/TYPO3_Blog_Controller_PostController.php 
> on line 29
>
> This is the function:
>
> public function indexAction() {
>                $blog = $this->blogRepository->findActive();
>                $output = '
>                        <h1>Posts of "' . $blog->getTitle() . '"</h1>
>                        <ol>';
>
>                foreach ($blog->getPosts() as $post) {
>                        $output .= '<li>' . $post->getTitle() . '</li>';
>                }
>
>                $output .= '</ol>';
>
>                return $output;
> }
>
> It seems, that blog created in the SetupController is not stored in 
> the blogRepository. I modified SetupController.php to test this:
>
>       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);
>
>                $blog->addPost($post);
>                                      //*** Test Begin ***
>                               $blog2 = 
> $this->blogRepository->findActive();
>                if ($blog2 == NULL)
>           return "Blog not created";
>                               //*** Test End ****
>
>                return 'Successfully created a blog';
>        }
>
> (The Code between Test Begin and Test End is from me)
>
> After I run  dev.tutorial.local/typo3.blog/setup/index I got the 
> message "Blog not created"
>
> I have tried the tutorial twice and stumbled back to the same error. 
> Can someone help me?
> Greetings
> Jonas
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow



More information about the Flow mailing list