Elgg  Version 2.3
InstantNotificationEvent.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Notifications;
4 
8 
15 
17 
18  const DEFAULT_ACTION_NAME = 'notify_user';
19 
20  /* @var string The name of the action/event */
21 
22  protected $action;
23 
24  /* @var string Action's object */
25  protected $object;
26 
27  /* @var ElggEntity User who triggered the event */
28  protected $actor;
29 
37  public function __construct(ElggData $object = null, $action = null, ElggEntity $actor = null) {
38 
39  $this->object = $object;
40 
41  $this->actor = $actor;
42  if (!isset($actor)) {
43  $this->actor = _elgg_services()->session->getLoggedInUser();
44  }
45 
46  $this->action = $action ? : self::DEFAULT_ACTION_NAME;
47  }
48 
58  public function getActor() {
59  return $this->actor;
60  }
61 
71  public function getActorGUID() {
72  return $this->actor ? $this->actor->guid : 0;
73  }
74 
84  public function getObject() {
85  return $this->object;
86  }
87 
93  public function getAction() {
94  return $this->action;
95  }
96 
102  public function getDescription() {
103  if (!$this->object) {
104  return $this->action;
105  }
106 
107  return implode(':', [
108  $this->action,
109  $this->object->getType(),
110  $this->object->getSubtype(),
111  ]);
112  }
113 
120  public function toObject() {
121  $obj = new stdClass();
122  $vars = get_object_vars($this);
123  foreach ($vars as $key => $value) {
124  if (is_object($value) && is_callable([$value, 'toObject'])) {
125  $obj->$key = $value->toObject();
126  } else {
127  $obj->$key = $value;
128  }
129  }
130  return $obj;
131  }
132 }
$value
Definition: longtext.php:42
toObject()
Export the notification event into a serializable object This method is mainly used for logging purpo...
$vars['entity']
$key
Definition: summary.php:34
getDescription()
Get a description of the event.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
__construct(ElggData $object=null, $action=null, ElggEntity $actor=null)
Constructor.
elgg ElggEntity
Definition: ElggEntity.js:16
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:5
elgg action
Definition: ajax.js:200