Elgg  Version master
Go to the documentation of this file.
1 <?php
3 namespace Elgg\Notifications;
10 #[\AllowDynamicProperties]
11 class Notification {
16  protected $from;
21  protected $to;
26  public $summary;
31  public $subject;
36  public $body;
41  public $language;
46  public $params;
51  public $url;
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;
73  if (isset($this->params['url'])) {
74  $this->url = $this->params['url'];
75  }
76  }
83  public function getSender(): \ElggEntity {
84  return $this->from;
85  }
92  public function getSenderGUID(): int {
93  return $this->from->guid;
94  }
101  public function getRecipient(): \ElggEntity {
102  return $this->to;
103  }
110  public function getRecipientGUID(): int {
111  return $this->to->guid;
112  }
119  public function toObject(): \stdClass {
120  $obj = new \stdClass();
121  $vars = get_object_vars($this);
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']);
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  }
140  return $obj;
141  }
149  public function __serialize(): array {
150  $vars = get_object_vars($this);
152  // unset the NotificationEventHandler as it can't be serialized and isn't needed during processing of the notification
153  unset($vars['params']['handler']);
155  return $vars;
156  }
157 }
Get the recipient entity.
Export notification.
Notification container.
Definition: generic.php:51
__construct(\ElggEntity $from,\ElggEntity $to, $language, $subject, $body, $summary= '', array $params=[])
Create a notification.
Get the recipient entity guid.
Get the sender entity.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
Called when the object is serialized.
Definition: theme.php:5
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