Elgg  Version 6.1
SubscriptionNotificationEvent.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Notifications;
4 
7 
15 
17 
21  protected $action;
22 
26  protected $object;
27 
31  protected $actor;
32 
42  public function __construct(\ElggData $object, string $action, \ElggEntity $actor = null) {
43  if (!$action) {
44  throw new InvalidArgumentException(__METHOD__ . ' expects a valid action name');
45  }
46 
47  $this->object = $object;
48 
49  $this->actor = $actor;
50  if (!isset($actor)) {
51  $this->actor = _elgg_services()->session_manager->getLoggedInUser();
52  }
53 
54  $this->action = $action;
55  }
56 
66  public function getActor() {
67  return $this->actor;
68  }
69 
79  public function getActorGUID() {
80  return $this->actor ? $this->actor->guid : 0;
81  }
82 
92  public function getObject() {
93  return $this->object;
94  }
95 
101  public function getAction() {
102  return $this->action;
103  }
104 
110  public function getDescription() {
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 }
Exception thrown if an argument is not of the expected type.
$value
Definition: generic.php:51
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
toObject()
Export the notification event into a serializable object This method is mainly used for logging purpo...
__construct(\ElggData $object, string $action,\ElggEntity $actor=null)
Create a notification event.