[TYPO3-mvc] How to replace deprecated method FlashMessageContainer->add()

Dirk Wenzel wenzel at webfox03.de
Sun Jan 19 23:56:39 CET 2014


Hi Steffen,
thank you for your hint.

In the meantime I decided to use the 'magic' __call method. It should be 
called if the method is not available (this means not implemented or not 
callable for instance because it is private):

My AbstractController class now contains this:
    /**
    * Provides a method addFlashMessage which is not available before
    * TYPO3 version 6.2
    * This method can be removed if version 6.1 is not supported anymore.
    *
    * @param string $name
    * @param array $arguments
    * @return void
    */
   public function __call($name, array $arguments) {
     if($name == 'addFlashMessage') {
       $this->controllerContext->getFlashMessageQueue()->addMessage(new 
\TYPO3\CMS\Core\Messaging\FlashMessage(current($arguments)));
     }
   }

It does the trick for 6.1 and should not be called under 6.2 (not tested 
yet)

Cheers
Dirk

Am 19.01.14 23:40, schrieb Steffen Müller:
> Hi.
>
> On 19.01.2014 14:10 Dirk Wenzel wrote:
>> Great! I was just about to add this method to my abstract controller
>> class. Now I can make it fit the 6.2 method (and make it available under
>> 6.1 too).
>
> Add it as a public method. This ensures your extension works in 6.1 and
> 6.2 in parallel. Otherwise you could end up in PHP Fatal errors
> PHP Fatal error:  Access level to BlogController::addFlashMessage() must
> be public


More information about the TYPO3-project-typo3v4mvc mailing list