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'");
48 if (
$name ===
'pagesetup' &&
$type ===
'system') {
50 'users_pagesetup' =>
true,
51 'profile_pagesetup' =>
true,
52 '_elgg_friends_page_setup' =>
true,
53 '_elgg_setup_collections_menu' =>
true,
54 '_elgg_user_settings_menu_setup' =>
true,
55 'developers_setup_menu' =>
true,
56 'groups_setup_sidebar_menus' =>
true,
57 'notifications_plugin_pagesetup' =>
true,
58 '_elgg_admin_pagesetup' =>
true,
59 'aalborg_theme_pagesetup' =>
true,
60 'login_as_add_topbar_link' =>
true,
62 if (!is_string($callback) || !isset($ignore[$callback])) {
63 $msg =
"Event [pagesetup, system] is deprecated. Use menu or page shell hooks.";
80 self::OPTION_STOPPABLE =>
true,
81 self::OPTION_DEPRECATION_MESSAGE =>
'',
82 self::OPTION_DEPRECATION_VERSION =>
'',
85 $events = $this->hasHandler($event,
$type);
86 if ($events &&
$options[self::OPTION_DEPRECATION_MESSAGE]) {
88 $options[self::OPTION_DEPRECATION_MESSAGE],
89 $options[self::OPTION_DEPRECATION_VERSION],
94 $events = $this->getOrderedHandlers($event,
$type);
97 foreach ($events as $callback) {
98 if (!is_callable($callback)) {
100 $this->logger->warn(
"handler for event [$event, $type] is not callable: " 101 . $this->inspector->describeCallable($callback));
106 if ($this->timer &&
$type ===
'system' && $event !==
'shutdown') {
107 $callback_as_string = $this->inspector->describeCallable($callback) .
"()";
109 $this->timer->begin([
"[$event,$type]", $callback_as_string]);
111 $this->timer->end([
"[$event,$type]", $callback_as_string]);
143 return $this->trigger(
"$event:before", $object_type,
$object);
164 self::OPTION_STOPPABLE =>
false,
166 return $this->trigger(
"$event:after", $object_type,
$object,
$options);
184 self::OPTION_DEPRECATION_MESSAGE =>
$message,
185 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