Project

General

Profile

Actions

Bug #73987

closed

\TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message); don't work

Added by Robert Heel over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
-
Start date:
2016-03-02
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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

Actions #1

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);

Actions #2

Updated by Robert Heel over 8 years ago

Thanks, this works!

Actions #3

Updated by Wouter Wolters over 8 years ago

  • Status changed from Needs Feedback to Closed

Welcome :)

Actions

Also available in: Atom PDF