Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
AbstractMessage Class Reference
Inheritance diagram for AbstractMessage:
MessageInterface Error Notice Success TestingMessage Warning

Public Member Functions

 __construct ( $text=null)
 
 getType ()
 
 getText ()
 
 setText ($text)
 
 setIdentifier ($identifier)
 
 getIdentifier ()
 
 setIsSticky ($isSticky=true)
 
 getIsSticky ()
 
 toString ()
 
 setData (array $data=[])
 
 getData ()
 

Protected Attributes

 $text
 
 $identifier
 
 $isSticky = false
 
 $data
 

Additional Inherited Members

- Data Fields inherited from MessageInterface
const DEFAULT_IDENTIFIER = 'default_message_identifier'
 
const TYPE_ERROR = 'error'
 
const TYPE_WARNING = 'warning'
 
const TYPE_NOTICE = 'notice'
 
const TYPE_SUCCESS = 'success'
 

Detailed Description

Abstract message model

@api

Since
100.0.2

Definition at line 14 of file AbstractMessage.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $text = null)
Parameters
string$text

Definition at line 39 of file AbstractMessage.php.

41  {
42  $this->text = $text;
43  }

Member Function Documentation

◆ getData()

getData ( )

Returns message data

Returns
array

Implements MessageInterface.

Definition at line 157 of file AbstractMessage.php.

158  {
159  return (array)$this->data;
160  }

◆ getIdentifier()

getIdentifier ( )

Getter message identifier

Returns
string

Implements MessageInterface.

Definition at line 91 of file AbstractMessage.php.

◆ getIsSticky()

getIsSticky ( )

Getter for flag. Whether message is sticky

Returns
bool @SuppressWarnings(PHPMD.BooleanGetMethodName)

Implements MessageInterface.

Definition at line 114 of file AbstractMessage.php.

◆ getText()

getText ( )

Getter for text of message

Returns
string

Implements MessageInterface.

Definition at line 57 of file AbstractMessage.php.

58  {
59  return (string)$this->text;
60  }

◆ getType()

getType ( )
abstract

Getter message type

Returns
string

Implements MessageInterface.

◆ setData()

setData ( array  $data = [])

Sets message data

Parameters
array$data
Returns
$this
Exceptions

Implements MessageInterface.

Definition at line 137 of file AbstractMessage.php.

138  {
139  array_walk_recursive(
140  $data,
141  function ($element) {
142  if (is_object($element) && !$element instanceof \Serializable) {
143  throw new \InvalidArgumentException('Only serializable content is allowed.');
144  }
145  }
146  );
147 
148  $this->data = $data;
149  return $this;
150  }
$element
Definition: element.phtml:12

◆ setIdentifier()

setIdentifier (   $identifier)

Setter message identifier

Parameters
string$identifier
Returns
$this

Implements MessageInterface.

Definition at line 80 of file AbstractMessage.php.

81  {
82  $this->identifier = $identifier;
83  return $this;
84  }

◆ setIsSticky()

setIsSticky (   $isSticky = true)

Setter for flag. Whether message is sticky

Parameters
bool$isSticky
Returns
$this

Implements MessageInterface.

Definition at line 102 of file AbstractMessage.php.

103  {
104  $this->isSticky = $isSticky;
105  return $this;
106  }

◆ setText()

setText (   $text)

Setter message text

Parameters
string$text
Returns
$this

Implements MessageInterface.

Definition at line 68 of file AbstractMessage.php.

69  {
70  $this->text = $text;
71  return $this;
72  }

◆ toString()

toString ( )

Retrieve message as a string

Returns
string

Implements MessageInterface.

Definition at line 124 of file AbstractMessage.php.

125  {
126  $out = $this->getType() . ': ' . $this->getIdentifier() . ': ' . $this->getText();
127  return $out;
128  }

Field Documentation

◆ $data

$data
protected

Definition at line 34 of file AbstractMessage.php.

◆ $identifier

$identifier
protected

Definition at line 24 of file AbstractMessage.php.

◆ $isSticky

$isSticky = false
protected

Definition at line 29 of file AbstractMessage.php.

◆ $text

$text
protected

Definition at line 19 of file AbstractMessage.php.


The documentation for this class was generated from the following file: