Elgg  Version 3.0
InstantNotificationEvent.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Notifications;
4 
5 use ElggData;
6 use ElggEntity;
7 use stdClass;
8 
15 
17 
18  const DEFAULT_ACTION_NAME = 'notify_user';
19 
23  protected $action;
24 
28  protected $object;
29 
33  protected $actor;
34 
42  public function __construct(ElggData $object = null, $action = null, ElggEntity $actor = null) {
43 
44  $this->object = $object;
45 
46  $this->actor = $actor;
47  if (!isset($actor)) {
48  $this->actor = _elgg_services()->session->getLoggedInUser();
49  }
50 
51  $this->action = $action ? : self::DEFAULT_ACTION_NAME;
52  }
53 
63  public function getActor() {
64  return $this->actor;
65  }
66 
76  public function getActorGUID() {
77  return $this->actor ? $this->actor->guid : 0;
78  }
79 
89  public function getObject() {
90  return $this->object;
91  }
92 
98  public function getAction() {
99  return $this->action;
100  }
101 
107  public function getDescription() {
108  if (!$this->object) {
109  return $this->action;
110  }
111 
112  return implode(':', [
113  $this->action,
114  $this->object->getType(),
115  $this->object->getSubtype(),
116  ]);
117  }
118 
125  public function toObject() {
126  $obj = new stdClass();
127  $vars = get_object_vars($this);
128  foreach ($vars as $key => $value) {
129  if (is_object($value) && is_callable([$value, 'toObject'])) {
130  $obj->$key = $value->toObject();
131  } else {
132  $obj->$key = $value;
133  }
134  }
135  return $obj;
136  }
137 }
toObject()
Export the notification event into a serializable object This method is mainly used for logging purpo...
getDescription()
Get a description of the event.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
$value
Definition: debugging.php:7
$vars['type']
Definition: save.php:11
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
__construct(ElggData $object=null, $action=null, ElggEntity $actor=null)
Constructor.
elgg action
Definition: ajax.js:200
elgg ElggEntity
Definition: ElggEntity.js:15