Moodle Plugin CI / test (push) Successful in 3m26s
BREAKING CHANGE: legacy management routes now fail closed and the legacy helper API is removed.
66 lines
2.0 KiB
PHP
66 lines
2.0 KiB
PHP
<?php
|
|
// This file is part of Moodle - http://moodle.org/
|
|
//
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
/**
|
|
* Library code used by the service control interfaces.
|
|
*
|
|
* @package local_webhooks
|
|
* @copyright 2017 "Valentin Popov" <info@valentineus.link>
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
|
|
/**
|
|
* Returns available event classes grouped by component.
|
|
*
|
|
* @return array
|
|
*/
|
|
function local_webhooks_get_event_choices() {
|
|
global $CFG;
|
|
|
|
$choices = [];
|
|
$debug = $CFG->debug;
|
|
|
|
// Deprecated core events emit debugging while loading; mirror the core tool_monitor workaround.
|
|
try {
|
|
$CFG->debug = DEBUG_NONE;
|
|
$classes = core_component::get_component_classes_in_namespace(null, 'event');
|
|
} finally {
|
|
$CFG->debug = $debug;
|
|
}
|
|
|
|
ksort($classes);
|
|
foreach (array_keys($classes) as $classname) {
|
|
if (
|
|
$classname === \core\event\unknown_logged::class
|
|
|| !is_subclass_of($classname, \core\event\base::class)
|
|
|| $classname::is_deprecated()
|
|
) {
|
|
continue;
|
|
}
|
|
|
|
$reflection = new ReflectionClass($classname);
|
|
if ($reflection->isAbstract()) {
|
|
continue;
|
|
}
|
|
|
|
$eventname = '\\' . ltrim($classname, '\\');
|
|
$component = core_component::get_component_from_classname($classname);
|
|
$choices[$component][base64_encode($eventname)] = $eventname;
|
|
}
|
|
|
|
return $choices;
|
|
}
|