MDL-61891 core_portfolio: Use manager method caller

This commit is contained in:
Andrew Nicols
2018-04-23 10:09:13 +08:00
parent 35e39d8b5d
commit 84f092a44b
+1 -26
View File
@@ -83,23 +83,6 @@ class provider implements
static::call_plugin_method('delete_portfolio_for_user', [$userid, $context]);
}
/**
* 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 $providerclass the provider class 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;
}
/**
* Internal method for looping through all of the portfolio plugins and calling a method.
*
@@ -108,14 +91,6 @@ class provider implements
*/
protected static function call_plugin_method($methodname, $params) {
// Note: Even if portfolio is _now_ disabled, there may be legacy data to export.
$plugins = \core_component::get_plugin_list('portfolio');
foreach (array_keys($plugins) as $plugin) {
$component = "portfolio_{$plugin}";
$classname = manager::get_provider_classname_for_component($component);
if (static::component_implements($classname, portfolio_provider::class)) {
// This portfolio plugin implements the portfolio_provider.
component_class_callback($classname, $methodname, $params);
}
}
\core_privacy\manager::plugintype_class_callback('portfolio', portfolio_provider::class, $methodname, $params);
}
}