mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-45216 events: Update to core/event/manager to return observer information.
This commit is contained in:
parent
e471fc6c9d
commit
1b9fb2e815
@ -215,15 +215,16 @@ class manager {
|
||||
self::$allobservers = array();
|
||||
|
||||
$plugintypes = \core_component::get_plugin_types();
|
||||
$plugintypes = array_merge(array('core' => 'not used'), $plugintypes);
|
||||
$systemdone = false;
|
||||
foreach ($plugintypes as $plugintype => $ignored) {
|
||||
$plugins = \core_component::get_plugin_list($plugintype);
|
||||
if (!$systemdone) {
|
||||
$plugins[] = "$CFG->dirroot/lib";
|
||||
$systemdone = true;
|
||||
if ($plugintype === 'core') {
|
||||
$plugins['core'] = "$CFG->dirroot/lib";
|
||||
} else {
|
||||
$plugins = \core_component::get_plugin_list($plugintype);
|
||||
}
|
||||
|
||||
foreach ($plugins as $fulldir) {
|
||||
foreach ($plugins as $plugin => $fulldir) {
|
||||
if (!file_exists("$fulldir/db/events.php")) {
|
||||
continue;
|
||||
}
|
||||
@ -232,7 +233,7 @@ class manager {
|
||||
if (!is_array($observers)) {
|
||||
continue;
|
||||
}
|
||||
self::add_observers($observers, "$fulldir/db/events.php");
|
||||
self::add_observers($observers, "$fulldir/db/events.php", $plugintype, $plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,8 +249,10 @@ class manager {
|
||||
* Add observers.
|
||||
* @param array $observers
|
||||
* @param string $file
|
||||
* @param string $plugintype Plugin type of the observer.
|
||||
* @param string $plugin Plugin of the observer.
|
||||
*/
|
||||
protected static function add_observers(array $observers, $file) {
|
||||
protected static function add_observers(array $observers, $file, $plugintype = null, $plugin = null) {
|
||||
global $CFG;
|
||||
|
||||
foreach ($observers as $observer) {
|
||||
@ -292,6 +295,8 @@ class manager {
|
||||
}
|
||||
$o->includefile = $observer['includefile'];
|
||||
}
|
||||
$o->plugintype = $plugintype;
|
||||
$o->plugin = $plugin;
|
||||
self::$allobservers[$observer['eventname']][] = $o;
|
||||
}
|
||||
}
|
||||
@ -306,6 +311,17 @@ class manager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all observers in the system. This is only for use for reporting on the list of observers in the system.
|
||||
*
|
||||
* @access private
|
||||
* @return array An array of stdClass with all core observer details.
|
||||
*/
|
||||
public static function get_all_observers() {
|
||||
self::init_all_observers();
|
||||
return self::$allobservers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all standard observers.
|
||||
* @param array $observers
|
||||
|
Loading…
x
Reference in New Issue
Block a user