From c4b06e48a6b95b06c5e2387d2880b93d7e5bb67a Mon Sep 17 00:00:00 2001
From: Paul Holden <paulh@moodle.com>
Date: Mon, 13 Nov 2023 10:56:52 +0000
Subject: [PATCH] MDL-72786 report_eventlist: final removal of deprecated event
 methods.

---
 .upgradenotes/MDL-72786-2024052421265765.yml |   7 +
 report/eventlist/classes/list_generator.php  | 139 +------------------
 2 files changed, 13 insertions(+), 133 deletions(-)
 create mode 100644 .upgradenotes/MDL-72786-2024052421265765.yml

diff --git a/.upgradenotes/MDL-72786-2024052421265765.yml b/.upgradenotes/MDL-72786-2024052421265765.yml
new file mode 100644
index 00000000000..84dd295a6ee
--- /dev/null
+++ b/.upgradenotes/MDL-72786-2024052421265765.yml
@@ -0,0 +1,7 @@
+issueNumber: MDL-72786
+notes:
+  report_eventlist:
+    - message: >-
+        The report_eventlist_list_generator methods deprecated previously have
+        been removed
+      type: deprecated
diff --git a/report/eventlist/classes/list_generator.php b/report/eventlist/classes/list_generator.php
index 6f76b303593..fa7b6319bc9 100644
--- a/report/eventlist/classes/list_generator.php
+++ b/report/eventlist/classes/list_generator.php
@@ -14,16 +14,6 @@
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
-/**
- * Event documentation
- *
- * @package   report_eventlist
- * @copyright 2014 Adrian Greeve <adrian@moodle.com>
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
 /**
  * Class for returning system event information.
  *
@@ -83,55 +73,11 @@ class report_eventlist_list_generator {
     }
 
     /**
-     * Return all of the core event files.
-     *
-     * @param bool $detail True will return details, but no abstract classes, False will return all events, but no details.
-     * @return array Core events.
-     *
      * @deprecated since 4.0 use {@see get_all_events_list} instead
      */
-    public static function get_core_events_list($detail = true) {
-        global $CFG;
-
-        debugging(__FUNCTION__ . '() is deprecated, please use report_eventlist_list_generator::get_all_events_list() instead',
-            DEBUG_DEVELOPER);
-
-        // 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;
-
-        $eventinformation = array();
-        $directory = $CFG->libdir . '/classes/event';
-        $files = self::get_file_list($directory);
-
-        // Remove exceptional events that will cause problems being displayed.
-        if (isset($files['unknown_logged'])) {
-            unset($files['unknown_logged']);
-        }
-        foreach ($files as $file => $location) {
-            $functionname = '\\core\\event\\' . $file;
-            // Check to see if this is actually a valid event.
-            if (method_exists($functionname, 'get_static_info')) {
-                if ($detail) {
-                    $ref = new \ReflectionClass($functionname);
-                    if (!$ref->isAbstract() && $file != 'manager') {
-                        $eventinformation = self::format_data($eventinformation, $functionname);
-                    }
-                } else {
-                    $eventinformation[$functionname] = $file;
-                }
-            }
-        }
-        // Now enable developer debugging as event information has been retrieved.
-        $CFG->debug          = $debuglevel;
-        $CFG->debugdisplay   = $debugdisplay;
-        $CFG->debugdeveloper = $debugdeveloper;
-        return $eventinformation;
+    #[\core\attribute\deprecated('::get_all_events_list', since: '4.0', mdl: 'MDL-72498', final: true)]
+    public static function get_core_events_list() {
+        \core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
     }
 
     /**
@@ -185,84 +131,11 @@ class report_eventlist_list_generator {
     }
 
     /**
-     * Returns a list of files (events) with a full directory path for events in a specified directory.
-     *
-     * @param string $directory location of files.
-     * @return array full location of files from the specified directory.
-     */
-    private static function get_file_list($directory) {
-        global $CFG;
-        $directoryroot = $CFG->dirroot;
-        $finaleventfiles = array();
-        if (is_dir($directory)) {
-            if ($handle = opendir($directory)) {
-                $eventfiles = scandir($directory);
-                foreach ($eventfiles as $file) {
-                    if ($file != '.' && $file != '..') {
-                        // Ignore the file if it is external to the system.
-                        if (strrpos($directory, $directoryroot) !== false) {
-                            $location = substr($directory, strlen($directoryroot));
-                            $eventname = substr($file, 0, -4);
-                            $finaleventfiles[$eventname] = $location  . '/' . $file;
-                        }
-                    }
-                }
-            }
-        }
-        return $finaleventfiles;
-    }
-
-    /**
-     * This function returns an array of all events for the plugins of the system.
-     *
-     * @param bool $detail True will return details, but no abstract classes, False will return all events, but no details.
-     * @return array A list of events from all plug-ins.
-     *
      * @deprecated since 4.0 use {@see get_all_events_list} instead
      */
-    public static function get_non_core_event_list($detail = true) {
-        global $CFG;
-
-        debugging(__FUNCTION__ . '() is deprecated, please use report_eventlist_list_generator::get_all_events_list() instead',
-            DEBUG_DEVELOPER);
-
-        // 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;
-
-        $noncorepluginlist = array();
-        $plugintypes = \core_component::get_plugin_types();
-        foreach ($plugintypes as $plugintype => $notused) {
-            $pluginlist = \core_component::get_plugin_list($plugintype);
-            foreach ($pluginlist as $plugin => $directory) {
-                $plugindirectory = $directory . '/classes/event';
-                foreach (self::get_file_list($plugindirectory) as $eventname => $notused) {
-                    $plugineventname = '\\' . $plugintype . '_' . $plugin . '\\event\\' . $eventname;
-                    // Check that this is actually an event.
-                    if (method_exists($plugineventname, 'get_static_info')) {
-                        if ($detail) {
-                            $ref = new \ReflectionClass($plugineventname);
-                            if (!$ref->isAbstract()) {
-                                $noncorepluginlist = self::format_data($noncorepluginlist, $plugineventname);
-                            }
-                        } else {
-                            $noncorepluginlist[$plugineventname] = $eventname;
-                        }
-                    }
-                }
-            }
-        }
-        // Now enable developer debugging as event information has been retrieved.
-        $CFG->debug          = $debuglevel;
-        $CFG->debugdisplay   = $debugdisplay;
-        $CFG->debugdeveloper = $debugdeveloper;
-
-        return $noncorepluginlist;
+    #[\core\attribute\deprecated('::get_all_events_list', since: '4.0', mdl: 'MDL-72498', final: true)]
+    public static function get_non_core_event_list() {
+        \core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
     }
 
     /**