Elgg  Version 3.0
Notification.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Notifications;
3 
11 class Notification {
12 
13  const ORIGIN_SUBSCRIPTIONS = 'subscriptions_service';
14  const ORIGIN_INSTANT = 'instant_notifications';
15 
19  protected $from;
20 
24  protected $to;
25 
29  public $summary;
30 
34  public $subject;
35 
39  public $body;
40 
44  public $language;
45 
49  public $params;
50 
54  public $url;
55 
69  public function __construct(\ElggEntity $from, \ElggEntity $to, $language, $subject, $body, $summary = '', array $params = []) {
70  $this->from = $from;
71  $this->to = $to;
72  $this->language = $language;
73  $this->subject = $subject;
74  $this->body = $body;
75  $this->summary = $summary;
76  $this->params = $params;
77 
78  if (isset($this->params['url'])) {
79  $this->url = $this->params['url'];
80  }
81  }
82 
88  public function getSender() {
89  return $this->from;
90  }
91 
97  public function getSenderGUID() {
98  return $this->from->guid;
99  }
100 
106  public function getRecipient() {
107  return $this->to;
108  }
109 
115  public function getRecipientGUID() {
116  return $this->to->guid;
117  }
118 
123  public function toObject() {
124  $obj = new \stdClass();
125  $vars = get_object_vars($this);
126  $vars = array_merge($this->params, $vars);
127  unset($vars['params']);
128  unset($vars['sender']);
129  unset($vars['recipient']);
130  unset($vars['subscriptions']);
131  unset($vars['action']);
132  unset($vars['object']);
133  foreach ($vars as $key => $value) {
134  if (is_object($value) && is_callable([$value, 'toObject'])) {
135  $obj->$key = $value->toObject();
136  } else {
137  $obj->$key = $value;
138  }
139  }
140  return $obj;
141  }
142 }
getRecipient()
Get the recipient entity.
toObject()
Export notification.
__construct(\ElggEntity $from,\ElggEntity $to, $language, $subject, $body, $summary= '', array $params=[])
Create a notification.
$new_user language
Definition: useradd.php:57
getRecipientGUID()
Get the recipient entity guid.
getSender()
Get the sender entity.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
$value
Definition: debugging.php:7
$CONFIG url
The full URL where Elgg is installed.
Definition: config.php:38
getSenderGUID()
Get the sender entity guid.
$vars['type']
Definition: save.php:11