Elgg  Version 6.1
Notification.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Notifications;
4 
10 #[\AllowDynamicProperties]
11 class Notification {
12 
16  protected $from;
17 
21  protected $to;
22 
26  public $summary;
27 
31  public $subject;
32 
36  public $body;
37 
41  public $language;
42 
46  public $params;
47 
51  public $url;
52 
64  public function __construct(\ElggEntity $from, \ElggEntity $to, $language, $subject, $body, $summary = '', array $params = []) {
65  $this->from = $from;
66  $this->to = $to;
67  $this->language = $language;
68  $this->subject = $subject;
69  $this->body = $body;
70  $this->summary = $summary;
71  $this->params = $params;
72 
73  if (isset($this->params['url'])) {
74  $this->url = $this->params['url'];
75  }
76  }
77 
83  public function getSender(): \ElggEntity {
84  return $this->from;
85  }
86 
92  public function getSenderGUID(): int {
93  return $this->from->guid;
94  }
95 
101  public function getRecipient(): \ElggEntity {
102  return $this->to;
103  }
104 
110  public function getRecipientGUID(): int {
111  return $this->to->guid;
112  }
113 
119  public function toObject(): \stdClass {
120  $obj = new \stdClass();
121  $vars = get_object_vars($this);
122 
123  $vars = array_merge($this->params, $vars);
124  unset($vars['params']);
125  unset($vars['sender']);
126  unset($vars['recipient']);
127  unset($vars['subscriptions']);
128  unset($vars['action']);
129  unset($vars['object']);
130  unset($vars['handler']);
131 
132  foreach ($vars as $key => $value) {
133  if (is_object($value) && is_callable([$value, 'toObject'])) {
134  $obj->$key = $value->toObject();
135  } else {
136  $obj->$key = $value;
137  }
138  }
139 
140  return $obj;
141  }
142 
149  public function __serialize(): array {
150  $vars = get_object_vars($this);
151 
152  // unset the NotificationEventHandler as it can't be serialized and isn't needed during processing of the notification
153  unset($vars['params']['handler']);
154 
155  return $vars;
156  }
157 }
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.
$vars
Definition: theme.php:5
getSenderGUID()
Get the sender entity guid.
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