Elgg  Version 1.9
Event.php
Go to the documentation of this file.
1 <?php
10  /* @var string The name of the action/event */
11  protected $action;
12 
13  /* @var string The type of the action's object */
14  protected $object_type;
15 
16  /* @var string the subtype of the action's object */
17  protected $object_subtype;
18 
19  /* @var int The identifier of the object (GUID for entity) */
20  protected $object_id;
21 
22  /* @var int The GUID of the user who triggered the event */
23  protected $actor_guid;
24 
25 
34  public function __construct(ElggData $object, $action, ElggUser $actor = null) {
35  if (elgg_instanceof($object)) {
36  $this->object_type = $object->getType();
37  $this->object_subtype = $object->getSubtype();
38  $this->object_id = $object->getGUID();
39  } else {
40  $this->object_type = $object->getType();
41  $this->object_subtype = $object->getSubtype();
42  $this->object_id = $object->id;
43  }
44 
45  if ($actor == null) {
46  $this->actor_guid = elgg_get_logged_in_user_guid();
47  } else {
48  $this->actor_guid = $actor->getGUID();
49  }
50 
51  $this->action = $action;
52  }
53 
59  public function getActor() {
60  return get_entity($this->actor_guid);
61  }
62 
68  public function getActorGUID() {
69  return $this->actor_guid;
70  }
71 
77  public function getObject() {
78  switch ($this->object_type) {
79  case 'object':
80  case 'user':
81  case 'site':
82  case 'group':
83  return get_entity($this->object_id);
84  break;
85  case 'relationship':
86  return get_relationship($this->object_id);
87  break;
88  case 'annotation':
89  return elgg_get_annotation_from_id($this->object_id);
90  break;
91  }
92  return null;
93  }
94 
100  public function getAction() {
101  return $this->action;
102  }
103 
109  public function getDescription() {
110  return "{$this->action}:{$this->object_type}:{$this->object_subtype}";
111  }
112 }
get_relationship($id)
Get a relationship by its ID.
getSubtype()
Return a subtype.
$object
Definition: upgrade.php:12
getActorGUID()
Get the GUID of the actor.
Definition: Event.php:68
getActor()
Get the actor of the event.
Definition: Event.php:59
getObject()
Get the object of the event.
Definition: Event.php:77
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an ElggEntity and optionally for type and subtype.
Definition: entities.php:1886
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
Definition: annotations.php:36
getType()
Return the type of the object - eg.
__construct(ElggData $object, $action, ElggUser $actor=null)
Create a notification event.
Definition: Event.php:34
getAction()
Get the name of the action.
Definition: Event.php:100
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:42
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:604
getDescription()
Get a description of the event.
Definition: Event.php:109
elgg action
Definition: ajax.js:178