‪TYPO3CMS  ‪main
FlashMessage.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 
27 {
33  protected ‪$storeInSession = false;
34 
43  public function ‪__construct(‪$message, ‪$title = '', ‪ContextualFeedbackSeverity ‪$severity = ContextualFeedbackSeverity::OK, ‪$storeInSession = false)
44  {
45  $this->‪setMessage(‪$message);
46  $this->‪setTitle(‪$title);
49  }
50 
57  public static function ‪createFromArray(array $data): self
58  {
59  return GeneralUtility::makeInstance(
60  static::class,
61  (string)$data['message'],
62  (string)($data['title'] ?? ''),
63  ContextualFeedbackSeverity::tryFrom($data['severity']) ?? ContextualFeedbackSeverity::OK,
64  (bool)($data['storeInSession'] ?? false)
65  );
66  }
67 
73  public function ‪isSessionMessage()
74  {
76  }
77 
84  {
85  $this->storeInSession = (bool)‪$storeInSession;
86  }
87 
91  public function ‪jsonSerialize(): array
92  {
93  $data = parent::jsonSerialize();
94  $data['storeInSession'] = ‪$this->storeInSession;
95  return $data;
96  }
97 }
‪TYPO3\CMS\Core\Messaging\AbstractMessage
Definition: AbstractMessage.php:26
‪TYPO3\CMS\Core\Messaging\FlashMessage\createFromArray
‪static static createFromArray(array $data)
Definition: FlashMessage.php:56
‪TYPO3\CMS\Core\Messaging\AbstractMessage\$message
‪string $message
Definition: AbstractMessage.php:28
‪TYPO3\CMS\Core\Messaging\AbstractMessage\setTitle
‪setTitle(string $title)
Definition: AbstractMessage.php:36
‪TYPO3\CMS\Core\Messaging\FlashMessage\isSessionMessage
‪bool isSessionMessage()
Definition: FlashMessage.php:72
‪TYPO3\CMS\Core\Messaging\AbstractMessage\$title
‪string $title
Definition: AbstractMessage.php:27
‪TYPO3\CMS\Core\Messaging\AbstractMessage\$severity
‪ContextualFeedbackSeverity $severity
Definition: AbstractMessage.php:29
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Core\Messaging\AbstractMessage\setMessage
‪setMessage(string $message)
Definition: AbstractMessage.php:46
‪TYPO3\CMS\Core\Messaging\FlashMessage\$storeInSession
‪bool $storeInSession
Definition: FlashMessage.php:32
‪TYPO3\CMS\Core\Messaging\FlashMessage\setStoreInSession
‪setStoreInSession($storeInSession)
Definition: FlashMessage.php:82
‪TYPO3\CMS\Core\Messaging\FlashMessage\__construct
‪__construct($message, $title='', ContextualFeedbackSeverity $severity=ContextualFeedbackSeverity::OK, $storeInSession=false)
Definition: FlashMessage.php:42
‪TYPO3\CMS\Core\Messaging\AbstractMessage\setSeverity
‪setSeverity(ContextualFeedbackSeverity $severity=ContextualFeedbackSeverity::OK)
Definition: AbstractMessage.php:64
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪TYPO3\CMS\Core\Messaging
Definition: AbstractMessage.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Messaging\FlashMessage\jsonSerialize
‪array jsonSerialize()
Definition: FlashMessage.php:90