Skip to content

Commit

Permalink
[TASK] Fix explanation of fourth parameter of FlashMessage (#1943)
Browse files Browse the repository at this point in the history
Part of the explanation was duplicate and the second explanation
was under the severities and not within the explanation of the
constructor for FlashMessage.

Additionall, the names of the arguments are used instead of
line numbers, which makes it more clear and prevents problems
in case the snippet is modified or arguments removed.

Releases: main, 11.5
  • Loading branch information
sypets authored Jul 12, 2022
1 parent 6e1e090 commit 275c787
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Documentation/ApiOverview/FlashMessages/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,25 @@ of class :php:`\TYPO3\CMS\Core\Messaging\FlashMessage`
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Messaging\FlashMessage;
// FlashMessage($message, $title, $severity = self::OK, $storeInSession)
$message = GeneralUtility::makeInstance(FlashMessage::class,
'My message text',
'Message Header',
FlashMessage::WARNING,
true
);
* Line 5: The text of the message
* Line 6: [optional] the header
* Line 7: [optional] the severity defaults to FlashMessage::OK
* Line 8: [optional] whether the message should be stored in the session or
only in the \TYPO3\CMS\Core\Messaging\FlashMessageQueue object (default is false)
:php:`$message:`
The text of the message
:php:`$title:`
[optional] the header
:php:`$severity:`
[optional] the severity (default: :php:`FlashMessage::OK`)
:php:`$storeInSession:`
[optional] :php:`true`: store in the session or :php:`false`: store
only in the :php:`\TYPO3\CMS\Core\Messaging\FlashMessageQueue` object. Storage
in the session should be used if you need the message to be still present after
a redirection (default: :php:`false`).


Flash messages severities
Expand All @@ -77,11 +84,6 @@ The severity is defined by using class constants provided by

* :php:`FlashMessage::ERROR` for errors

The fourth parameter passed to the constructor is a flag that
indicates whether the message should be stored in the session or not (the
default is not). Storage in the session should be used if you need the
message to be still present after a redirection.

In backend modules you can then make that message appear on top of the
module after a page refresh or the rendering of the next page request
or render it on your own where ever you want.
Expand Down

0 comments on commit 275c787

Please sign in to comment.