Elgg  Version master
Event.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
3 
5 
11 class Event {
12 
22  public function __construct(
23  protected PublicContainer $dic,
24  protected string $name,
25  protected string $type,
26  protected $value = null,
27  protected $params = []
28  ) {
29  }
30 
36  public function getName(): string {
37  return $this->name;
38  }
39 
45  public function getType(): string {
46  return $this->type;
47  }
48 
54  public function getObject() {
55  return elgg_extract('object', $this->params);
56  }
57 
63  public function getValue() {
64  return $this->value;
65  }
66 
75  public function setValue($value): void {
76  $this->value = $value;
77  }
78 
84  public function getParams() {
85  return $this->params;
86  }
87 
97  public function getParam(string $key, $default = null) {
98  if (!is_array($this->params)) {
99  return $default;
100  }
101 
102  return elgg_extract($key, $this->params, $default);
103  }
104 
110  public function getEntityParam(): ?\ElggEntity {
111  if (isset($this->params['entity']) && $this->params['entity'] instanceof \ElggEntity) {
112  return $this->params['entity'];
113  }
114 
115  return null;
116  }
117 
123  public function getUserParam(): ?\ElggUser {
124  if (isset($this->params['user']) && $this->params['user'] instanceof \ElggUser) {
125  return $this->params['user'];
126  }
127 
128  return null;
129  }
130 
136  public function elgg(): PublicContainer {
137  return $this->dic;
138  }
139 
145  public function getSequenceID(): ?string {
146  return elgg_extract('_elgg_sequence_id', $this->params);
147  }
148 }
$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:145
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
getParams()
Get the parameters passed to the trigger call.
Definition: Event.php:84
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:123
getName()
Get the name of the event.
Definition: Event.php:36
$data value
Definition: default.php:23
$type
Definition: delete.php:21
$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:110
getParam(string $key, $default=null)
Get an element of the params array.
Definition: Event.php:97
elgg()
Get the DI container.
Definition: Event.php:136
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:63
getObject()
Get the object of the event.
Definition: Event.php:54
getType()
Get the type of the event object.
Definition: Event.php:45
setValue($value)
Update the value.
Definition: Event.php:75
Models an event passed to event handlers.
Definition: Event.php:11
__construct(protected PublicContainer $dic, protected string $name, protected string $type, protected $value=null, protected $params=[])
Constructor.
Definition: Event.php:22