Elgg  Version master
ElggSystemMessage.php
Go to the documentation of this file.
1 <?php
11 
15  protected $message;
16 
20  protected $ttl = -1;
21 
25  protected $type;
26 
30  protected $vars = [];
31 
35  protected $link = '';
36 
43  public function __construct(string $message, string $type = 'success') {
44  $this->message = $message;
45  $this->type = $type;
46  }
47 
63  public static function factory(array $options): \ElggSystemMessage {
64  $message = new static(elgg_extract('message', $options));
65  unset($options['message']);
66 
67  foreach ($options as $key => $value) {
68  $func = 'set' . ucfirst($key);
69  if (is_callable([$message, $func])) {
70  $message->$func($value);
71  } else {
72  $message->vars[$key] = $value;
73  }
74  }
75 
76  return $message;
77  }
78 
85  public function setMessage(string $message): void {
86  $this->message = $message;
87  }
88 
94  public function getMessage(): string {
95  return $this->message;
96  }
97 
104  public function setType(string $type): void {
105  $this->type = $type;
106  }
107 
113  public function getType(): string {
114  return $this->type;
115  }
116 
124  public function setTtl(int $ttl): void {
125  $this->ttl = $ttl;
126  }
127 
133  public function getTtl(): int {
134  return $this->ttl;
135  }
136 
144  public function getVars(array $extras = []): array {
145  return array_merge($this->vars, $extras);
146  }
147 
153  public function __toString(): string {
154  return $this->message;
155  }
156 }
__toString()
This magic method is used for setting a string value for the object.
setType(string $type)
Set the type.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
Elgg System Message.
getTtl()
Returns the time to live.
getVars(array $extras=[])
Returns the extra vars set during the factory.
getType()
Returns the message type.
setTtl(int $ttl)
Set the time to live.
$value
Definition: generic.php:51
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
$result message
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
Definition: language.php:20
getMessage()
Returns the message.
setMessage(string $message)
Set the message.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
static factory(array $options)
Create an ElggSystemMessage from an associative array.
__construct(string $message, string $type= 'success')
constructor