‪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 
56  public static function ‪createFromArray(array $data): self
57  {
58  return GeneralUtility::makeInstance(
59  static::class,
60  (string)($data['message'] ?? ''),
61  (string)($data['title'] ?? ''),
62  ‪ContextualFeedbackSeverity::tryFrom($data['severity'] ?? ContextualFeedbackSeverity::OK->value) ?? ContextualFeedbackSeverity::OK,
63  (bool)($data['storeInSession'] ?? false)
64  );
65  }
66 
72  public function ‪isSessionMessage()
73  {
75  }
76 
83  {
84  $this->storeInSession = (bool)‪$storeInSession;
85  }
86 
90  public function ‪jsonSerialize(): array
91  {
92  $data = parent::jsonSerialize();
93  $data['storeInSession'] = ‪$this->storeInSession;
94  return $data;
95  }
96 }
‪TYPO3\CMS\Core\Messaging\AbstractMessage
Definition: AbstractMessage.php:26
‪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:71
‪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\Frontend\Content\tryFrom
‪@ tryFrom
Definition: ContentSlideMode.php:27
‪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:81
‪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\Messaging\FlashMessage\createFromArray
‪static createFromArray(array $data)
Definition: FlashMessage.php:55
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Messaging\FlashMessage\jsonSerialize
‪array jsonSerialize()
Definition: FlashMessage.php:89