Elgg  Version master
Event.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
3 
5 
11 class Event {
12 
16  protected $dic;
17 
21  protected $name;
22 
26  protected $type;
27 
31  protected $value;
32 
36  protected $params;
37 
47  public function __construct(PublicContainer $dic, string $name, string $type, $value = null, $params = []) {
48  $this->dic = $dic;
49  $this->name = $name;
50  $this->type = $type;
51  $this->value = $value;
52  $this->params = $params;
53  }
54 
60  public function getName(): string {
61  return $this->name;
62  }
63 
69  public function getType(): string {
70  return $this->type;
71  }
72 
78  public function getObject() {
79  return elgg_extract('object', $this->params);
80  }
81 
87  public function getValue() {
88  return $this->value;
89  }
90 
99  public function setValue($value): void {
100  $this->value = $value;
101  }
102 
108  public function getParams() {
109  return $this->params;
110  }
111 
121  public function getParam(string $key, $default = null) {
122  if (!is_array($this->params)) {
123  return $default;
124  }
125 
126  return elgg_extract($key, $this->params, $default);
127  }
128 
134  public function getEntityParam(): ?\ElggEntity {
135  if (isset($this->params['entity']) && $this->params['entity'] instanceof \ElggEntity) {
136  return $this->params['entity'];
137  }
138 
139  return null;
140  }
141 
147  public function getUserParam(): ?\ElggUser {
148  if (isset($this->params['user']) && $this->params['user'] instanceof \ElggUser) {
149  return $this->params['user'];
150  }
151 
152  return null;
153  }
154 
160  public function elgg(): PublicContainer {
161  return $this->dic;
162  }
163 
169  public function getSequenceID(): ?string {
170  return elgg_extract('_elgg_sequence_id', $this->params);
171  }
172 }
$default
Definition: checkbox.php:30
$params
Saves global plugin settings.
Definition: save.php:13
getSequenceID()
When the event is part of a sequence a unique ID is set for each sequence.
Definition: Event.php:169
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
getParams()
Get the parameters passed to the trigger call.
Definition: Event.php:108
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
getUserParam()
Gets the "user" key from the params if it holds an ElggUser.
Definition: Event.php:147
getName()
Get the name of the event.
Definition: Event.php:60
$data value
Definition: default.php:27
$type
Definition: delete.php:22
$value
Definition: generic.php:51
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
getEntityParam()
Gets the "entity" key from the params if it holds an ElggEntity.
Definition: Event.php:134
getParam(string $key, $default=null)
Get an element of the params array.
Definition: Event.php:121
elgg()
Get the DI container.
Definition: Event.php:160
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
getValue()
Get the current value of the event.
Definition: Event.php:87
__construct(PublicContainer $dic, string $name, string $type, $value=null, $params=[])
Constructor.
Definition: Event.php:47
getObject()
Get the object of the event.
Definition: Event.php:78
$site name
Definition: settings.php:15
getType()
Get the type of the event object.
Definition: Event.php:69
setValue($value)
Update the value.
Definition: Event.php:99
Models an event passed to event handlers.
Definition: Event.php:11