Bug #73987
closed\TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message); don't work
0%
Description
The TYPO3 6.2 example of flash messages doesn't work in TYPO3 7.6
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
'My message text',
'Message Header', // the header is optional
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, // the severity is optional as well and defaults to \TYPO3\CMS\Core\Messaging\FlashMessage::OK
TRUE // optional, whether the message should be stored in the session or only in the \TYPO3\CMS\Core\Messaging\FlashMessageQueue object (default is FALSE)
);
\TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
PHP Fatal error: Call to undefined method tx_odsosm_tcemain::enqueue() in /usr/share/typo3/typo3_src-7.6.4/typo3/sysext/core/Classes/Messaging/FlashMessageQueue.php on line 76
Updated by Wouter Wolters over 8 years ago
- Status changed from New to Needs Feedback
You are calling your code statically, which is not the case with this function and that is the reason your call fails!
Please try this:
$flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
$messageQueue = $flashMessageService->getMessageQueueByIdentifier();
$messageQueue->addMessage($message);