Skip to content

Commit

Permalink
Merge branch 'MDL-72498-311' of git://github.com/paulholden/moodle in…
Browse files Browse the repository at this point in the history
…to MOODLE_311_STABLE
  • Loading branch information
vmdef authored and andrewnicols committed Oct 12, 2021
2 parents 6f4d296 + 72b8b2e commit 318637c
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion report/eventlist/classes/list_generator.php
Expand Up @@ -40,7 +40,47 @@ class report_eventlist_list_generator {
* @return array All events.
*/
public static function get_all_events_list($detail = true) {
return array_merge(self::get_core_events_list($detail), self::get_non_core_event_list($detail));
global $CFG;

// Disable developer debugging as deprecated events will fire warnings.
// Setup backup variables to restore the following settings back to what they were when we are finished.
$debuglevel = $CFG->debug;
$debugdisplay = $CFG->debugdisplay;
$debugdeveloper = $CFG->debugdeveloper;
$CFG->debug = 0;
$CFG->debugdisplay = false;
$CFG->debugdeveloper = false;

// List of exceptional events that will cause problems if displayed.
$eventsignore = [
\core\event\unknown_logged::class,
\logstore_legacy\event\legacy_logged::class,
];

$eventinformation = [];

$events = core_component::get_component_classes_in_namespace(null, 'event');
foreach (array_keys($events) as $event) {
// We need to filter all classes that extend event base, or the base class itself.
if (is_a($event, \core\event\base::class, true) && !in_array($event, $eventsignore)) {
if ($detail) {
$reflectionclass = new ReflectionClass($event);
if (!$reflectionclass->isAbstract()) {
$eventinformation = self::format_data($eventinformation, "\\${event}");
}
} else {
$parts = explode('\\', $event);
$eventinformation["\\${event}"] = array_shift($parts);
}
}
}

// Now enable developer debugging as event information has been retrieved.
$CFG->debug = $debuglevel;
$CFG->debugdisplay = $debugdisplay;
$CFG->debugdeveloper = $debugdeveloper;

return $eventinformation;
}

/**
Expand Down

0 comments on commit 318637c

Please sign in to comment.