TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AbstractMessage.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Messaging;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 abstract class AbstractMessage
21 {
22  const NOTICE = -2;
23  const INFO = -1;
24  const OK = 0;
25  const WARNING = 1;
26  const ERROR = 2;
27 
33  protected $title = '';
34 
40  protected $message = '';
41 
47  protected $severity = self::OK;
48 
54  public function getTitle()
55  {
56  return $this->title;
57  }
58 
65  public function setTitle($title)
66  {
67  $this->title = (string)$title;
68  }
69 
75  public function getMessage()
76  {
77  return $this->message;
78  }
79 
86  public function setMessage($message)
87  {
88  $this->message = (string)$message;
89  }
90 
96  public function getSeverity()
97  {
98  return $this->severity;
99  }
100 
107  public function setSeverity($severity = self::OK)
108  {
109  $this->severity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($severity, self::NOTICE, self::ERROR, self::OK);
110  }
111 
118  public function __toString()
119  {
120  $severities = [
121  self::INFO => 'INFO',
122  self::OK => 'OK',
123  self::WARNING => 'WARNING',
124  self::ERROR => 'ERROR'
125  ];
126  $title = '';
127  if (!empty($this->title)) {
128  $title = ' - ' . $this->title;
129  }
130  return $severities[$this->severity] . $title . ': ' . $this->message;
131  }
132 }
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:31