Skip to content

Commit

Permalink
MDL-61891 core_plagiarism: Use manager method caller
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Apr 23, 2018
1 parent 7fe24b6 commit 35e39d8
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions plagiarism/classes/privacy/provider.php
Expand Up @@ -66,23 +66,6 @@ public static function export_plagiarism_user_data(int $userid, \context $contex
static::call_plugin_method('export_plagiarism_user_data', [$userid, $context, $subcontext, $linkarray]);
}

/**
* Checks whether the component's provider class implements the specified interface.
* This can either be implemented directly, or by implementing a descendant (extension) of the specified interface.
*
* @param string $component the frankenstyle component name.
* @param string $interface the name of the interface we want to check.
* @return bool True if an implementation was found, false otherwise.
*/
protected static function component_implements(string $providerclass, string $interface) : bool {
if (class_exists($providerclass)) {
$rc = new \ReflectionClass($providerclass);
return $rc->implementsInterface($interface);
}

return false;
}

/**
* Deletes all user content for a context in all plagiarism plugins.
*
Expand Down Expand Up @@ -110,14 +93,6 @@ public static function delete_plagiarism_for_user(int $userid, \context $context
*/
protected static function call_plugin_method($methodname, $params) {
// Note: Even if plagiarism is _now_ disabled, there may be legacy data to export.
$plugins = \core_component::get_plugin_list('plagiarism');
foreach (array_keys($plugins) as $plugin) {
$component = "plagiarism_{$plugin}";
$classname = manager::get_provider_classname_for_component($component);
if (static::component_implements($classname, plagiarism_provider::class)) {
// This plagiarism plugin implements the plagiarism_provider.
component_class_callback($classname, $methodname, $params);
}
}
\core_privacy\manager::plugintype_class_callback('plagiarism', plagiarism_provider::class, $methodname, $params);
}
}

0 comments on commit 35e39d8

Please sign in to comment.