Elgg  Version 4.3
Notification.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Notifications;
4 
10 class Notification {
11 
15  protected $from;
16 
20  protected $to;
21 
25  public $summary;
26 
30  public $subject;
31 
35  public $body;
36 
40  public $language;
41 
45  public $params;
46 
50  public $url;
51 
63  public function __construct(\ElggEntity $from, \ElggEntity $to, $language, $subject, $body, $summary = '', array $params = []) {
64  $this->from = $from;
65  $this->to = $to;
66  $this->language = $language;
67  $this->subject = $subject;
68  $this->body = $body;
69  $this->summary = $summary;
70  $this->params = $params;
71 
72  if (isset($this->params['url'])) {
73  $this->url = $this->params['url'];
74  }
75  }
76 
82  public function getSender(): \ElggEntity {
83  return $this->from;
84  }
85 
91  public function getSenderGUID(): int {
92  return $this->from->guid;
93  }
94 
100  public function getRecipient(): \ElggEntity {
101  return $this->to;
102  }
103 
109  public function getRecipientGUID(): int {
110  return $this->to->guid;
111  }
112 
118  public function toObject(): \stdClass {
119  $obj = new \stdClass();
120  $vars = get_object_vars($this);
121 
122  $vars = array_merge($this->params, $vars);
123  unset($vars['params']);
124  unset($vars['sender']);
125  unset($vars['recipient']);
126  unset($vars['subscriptions']);
127  unset($vars['action']);
128  unset($vars['object']);
129  unset($vars['handler']);
130 
131  foreach ($vars as $key => $value) {
132  if (is_object($value) && is_callable([$value, 'toObject'])) {
133  $obj->$key = $value->toObject();
134  } else {
135  $obj->$key = $value;
136  }
137  }
138 
139  return $obj;
140  }
141 
148  public function __serialize(): array {
149  $vars = get_object_vars($this);
150 
151  // unset the NotificationEventHandler as it can't be serialized and isn't needed during processing of the notification
152  unset($vars['params']['handler']);
153 
154  return $vars;
155  }
156 }
getRecipient()
Get the recipient entity.
toObject()
Export notification.
Notification container.
$value
Definition: generic.php:51
__construct(\ElggEntity $from,\ElggEntity $to, $language, $subject, $body, $summary= '', array $params=[])
Create a notification.
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:44
__serialize()
Called when the object is serialized.
getSenderGUID()
Get the sender entity guid.
$vars['head']
Definition: html.php:24
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of either verbatim or with modifications and or translated into another language(Hereinafter, translation is included without limitation in the term"modification".) Each licensee is addressed as"you".Activities other than copying