17 const OPTION_STOPPABLE =
'stoppable';
18 const OPTION_DEPRECATION_MESSAGE =
'deprecation_message';
19 const OPTION_DEPRECATION_VERSION =
'deprecation_version';
35 $this->inspector = $inspector;
42 if (in_array(
$type, [
'member',
'friend',
'member_of_site',
'attached'])
43 && in_array(
$name, [
'create',
'update',
'delete'])) {
44 $this->logger->error(
"'$name, $type' event is no longer triggered. Update your event registration " 45 .
"to use '$name, relationship'");
59 self::OPTION_STOPPABLE =>
true,
60 self::OPTION_DEPRECATION_MESSAGE =>
'',
61 self::OPTION_DEPRECATION_VERSION =>
'',
64 $events = $this->hasHandler($event,
$type);
65 if ($events &&
$options[self::OPTION_DEPRECATION_MESSAGE]) {
67 $options[self::OPTION_DEPRECATION_MESSAGE],
68 $options[self::OPTION_DEPRECATION_VERSION],
73 $events = $this->getOrderedHandlers($event,
$type);
76 foreach ($events as $callback) {
77 if (!is_callable($callback)) {
79 $this->logger->warn(
"handler for event [$event, $type] is not callable: " 80 . $this->inspector->describeCallable($callback));
85 if ($this->timer &&
$type ===
'system' && $event !==
'shutdown') {
86 $callback_as_string = $this->inspector->describeCallable($callback) .
"()";
88 $this->timer->begin([
"[$event,$type]", $callback_as_string]);
90 $this->timer->end([
"[$event,$type]", $callback_as_string]);
122 return $this->trigger(
"$event:before", $object_type,
$object);
143 self::OPTION_STOPPABLE =>
false,
145 return $this->trigger(
"$event:after", $object_type,
$object,
$options);
163 self::OPTION_DEPRECATION_MESSAGE =>
$message,
164 self::OPTION_DEPRECATION_VERSION =>
$version,
$object
These two snippets demonstrates triggering an event and how to register for that event.
trigger($event, $type, $object=null, array $options=array())
Triggers an Elgg event.
triggerBefore($event, $object_type, $object=null)
Trigger a "Before event" indicating a process is about to begin.
if($guid==elgg_get_logged_in_user_guid()) $name
registerHandler($name, $type, $callback, $priority=500)
{}
triggerAfter($event, $object_type, $object=null)
Trigger an "After event" indicating a process has finished.
triggerDeprecated($event, $object_type, $object=null, $message, $version)
Trigger an event normally, but send a notice about deprecated use if any handlers are registered...
$args
Some servers don't allow PHP to check the rewrite, so try via AJAX.
trait Profilable
Make an object accept a timer.
__construct(Inspector $inspector=null)
Constructor.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
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