Elgg  Version 6.1
InstantNotificationEvent.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Notifications;
4 
6 
14 
16 
17  const DEFAULT_ACTION_NAME = 'notify_user';
18 
22  protected $action;
23 
27  protected $object;
28 
32  protected $actor;
33 
41  public function __construct(\ElggData $object = null, string $action = null, \ElggEntity $actor = null) {
42 
43  $this->object = $object;
44 
45  $this->actor = $actor;
46  if (!isset($actor)) {
47  $this->actor = _elgg_services()->session_manager->getLoggedInUser();
48  }
49 
50  $this->action = $action ?: self::DEFAULT_ACTION_NAME;
51  }
52 
62  public function getActor() {
63  return $this->actor;
64  }
65 
75  public function getActorGUID() {
76  return $this->actor ? $this->actor->guid : 0;
77  }
78 
88  public function getObject() {
89  return $this->object;
90  }
91 
97  public function getAction() {
98  return $this->action;
99  }
100 
106  public function getDescription() {
107  if (!$this->object) {
108  return $this->action;
109  }
110 
111  return implode(':', [
112  $this->action,
113  $this->object->getType(),
114  $this->object->getSubtype(),
115  ]);
116  }
117 
124  public function toObject() {
125  $obj = new \stdClass();
126 
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 
136  return $obj;
137  }
138 }
__construct(\ElggData $object=null, string $action=null,\ElggEntity $actor=null)
Constructor.
toObject()
Export the notification event into a serializable object This method is mainly used for logging purpo...
$value
Definition: generic.php:51
getDescription()
Get a description of the event.
A generic class that contains shared code among , , and .
Definition: ElggData.php:10
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
$vars
Definition: theme.php:5
Notification event interface.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353