mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-40220 use new core_component::normalize_component()
This commit is contained in:
parent
1c74b26090
commit
56da374e1e
@ -39,7 +39,7 @@ class tool_customlang_filter_form extends moodleform {
|
||||
// Component
|
||||
$options = array();
|
||||
foreach (tool_customlang_utils::list_components() as $component => $normalized) {
|
||||
list($type, $plugin) = normalize_component($normalized);
|
||||
list($type, $plugin) = core_component::normalize_component($normalized);
|
||||
if ($type == 'core' and is_null($plugin)) {
|
||||
$plugin = 'moodle';
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class tool_customlang_utils {
|
||||
if ($filename !== clean_param($filename, PARAM_FILE)) {
|
||||
throw new coding_exception('Incorrect file name '.s($filename));
|
||||
}
|
||||
list($package, $subpackage) = normalize_component($component);
|
||||
list($package, $subpackage) = core_component::normalize_component($component);
|
||||
$packageinfo = " * @package $package";
|
||||
if (!is_null($subpackage)) {
|
||||
$packageinfo .= "\n * @subpackage $subpackage";
|
||||
|
@ -250,7 +250,7 @@ class tool_installaddon_installer {
|
||||
exit();
|
||||
}
|
||||
|
||||
list($plugintype, $pluginname) = normalize_component($data->component);
|
||||
list($plugintype, $pluginname) = core_component::normalize_component($data->component);
|
||||
|
||||
$plugintypepath = $this->get_plugintype_root($plugintype);
|
||||
|
||||
|
@ -332,7 +332,7 @@ class tool_installaddon_validator {
|
||||
|
||||
if (isset($info[$type.'->component'])) {
|
||||
$this->versionphp['component'] = $info[$type.'->component'];
|
||||
list($reqtype, $reqname) = normalize_component($this->versionphp['component']);
|
||||
list($reqtype, $reqname) = core_component::normalize_component($this->versionphp['component']);
|
||||
if ($reqtype !== $this->assertions['plugintype']) {
|
||||
$this->add_message(self::ERROR, 'componentmismatchtype', array(
|
||||
'expected' => $this->assertions['plugintype'],
|
||||
|
@ -260,7 +260,7 @@ class comment {
|
||||
throw new coding_exception('You cannot change the component of a comment once it has been set');
|
||||
}
|
||||
$this->component = $component;
|
||||
list($this->plugintype, $this->pluginname) = normalize_component($component);
|
||||
list($this->plugintype, $this->pluginname) = core_component::normalize_component($component);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@ class dndupload_handler {
|
||||
// Loop through all modules to find handlers.
|
||||
$mods = get_plugin_list_with_function('mod', 'dndupload_register');
|
||||
foreach ($mods as $component => $funcname) {
|
||||
list($modtype, $modname) = normalize_component($component);
|
||||
list($modtype, $modname) = core_component::normalize_component($component);
|
||||
if ($modnames && !array_key_exists($modname, $modnames)) {
|
||||
continue; // Module is deactivated (hidden) at the site level.
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ abstract class gradingform_controller {
|
||||
global $DB;
|
||||
|
||||
$this->context = $context;
|
||||
list($type, $name) = normalize_component($component);
|
||||
list($type, $name) = core_component::normalize_component($component);
|
||||
$this->component = $type.'_'.$name;
|
||||
$this->area = $area;
|
||||
$this->areaid = $areaid;
|
||||
|
@ -139,7 +139,7 @@ class grading_manager {
|
||||
*/
|
||||
public function set_component($component) {
|
||||
$this->areacache = null;
|
||||
list($type, $name) = normalize_component($component);
|
||||
list($type, $name) = core_component::normalize_component($component);
|
||||
$this->component = $type.'_'.$name;
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ class grading_manager {
|
||||
public static function available_areas($component) {
|
||||
global $CFG;
|
||||
|
||||
list($plugintype, $pluginname) = normalize_component($component);
|
||||
list($plugintype, $pluginname) = core_component::normalize_component($component);
|
||||
|
||||
if ($component === 'core_grading') {
|
||||
return array();
|
||||
|
@ -2895,7 +2895,7 @@ function get_component_string($component, $contextlevel) {
|
||||
}
|
||||
}
|
||||
|
||||
list($type, $name) = normalize_component($component);
|
||||
list($type, $name) = core_component::normalize_component($component);
|
||||
$dir = core_component::get_plugin_directory($type, $name);
|
||||
if (!file_exists($dir)) {
|
||||
// plugin not installed, bad luck, there is no way to find the name
|
||||
|
@ -342,7 +342,7 @@ function uninstall_plugin($type, $name) {
|
||||
function get_component_version($component, $source='installed') {
|
||||
global $CFG, $DB;
|
||||
|
||||
list($type, $name) = normalize_component($component);
|
||||
list($type, $name) = core_component::normalize_component($component);
|
||||
|
||||
// moodle core or a core subsystem
|
||||
if ($type === 'core') {
|
||||
|
@ -414,7 +414,7 @@ function message_get_providers_for_user($userid) {
|
||||
|
||||
// If the component is an enrolment plugin, check it is enabled
|
||||
foreach ($providers as $providerid => $provider) {
|
||||
list($type, $name) = normalize_component($provider->component);
|
||||
list($type, $name) = core_component::normalize_component($provider->component);
|
||||
if ($type == 'enrol' && !enrol_is_enabled($name)) {
|
||||
unset($providers[$providerid]);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ abstract class renderer_factory_base implements renderer_factory {
|
||||
global $CFG; // needed in included files
|
||||
|
||||
// standardize component name ala frankenstyle
|
||||
list($plugin, $type) = normalize_component($component);
|
||||
list($plugin, $type) = core_component::normalize_component($component);
|
||||
if ($type === null) {
|
||||
$component = $plugin;
|
||||
} else {
|
||||
|
@ -868,7 +868,7 @@ class plugin_manager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for the core function {@link normalize_component()}.
|
||||
* Wrapper for the core function {@link core_component::normalize_component()}.
|
||||
*
|
||||
* This is here just to make it possible to mock it in unit tests.
|
||||
*
|
||||
@ -876,7 +876,7 @@ class plugin_manager {
|
||||
* @return array
|
||||
*/
|
||||
protected function normalize_component($component) {
|
||||
return normalize_component($component);
|
||||
return core_component::normalize_component($component);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1619,7 +1619,7 @@ class available_update_checker {
|
||||
// is a real update with higher version. That is, the $componentchange
|
||||
// is present in the array of {@link available_update_info} objects
|
||||
// returned by the plugin's available_updates() method.
|
||||
list($plugintype, $pluginname) = normalize_component($component);
|
||||
list($plugintype, $pluginname) = core_component::normalize_component($component);
|
||||
if (!empty($plugins[$plugintype][$pluginname])) {
|
||||
$availableupdates = $plugins[$plugintype][$pluginname]->available_updates();
|
||||
if (!empty($availableupdates)) {
|
||||
@ -1974,7 +1974,7 @@ class available_update_deployer {
|
||||
public function plugin_external_source(available_update_info $info) {
|
||||
|
||||
$paths = core_component::get_plugin_types();
|
||||
list($plugintype, $pluginname) = normalize_component($info->component);
|
||||
list($plugintype, $pluginname) = core_component::normalize_component($info->component);
|
||||
$pluginroot = $paths[$plugintype].'/'.$pluginname;
|
||||
|
||||
if (is_dir($pluginroot.'/.git')) {
|
||||
@ -2033,7 +2033,7 @@ class available_update_deployer {
|
||||
|
||||
$pluginrootpaths = core_component::get_plugin_types();
|
||||
|
||||
list($plugintype, $pluginname) = normalize_component($info->component);
|
||||
list($plugintype, $pluginname) = core_component::normalize_component($info->component);
|
||||
|
||||
if (empty($pluginrootpaths[$plugintype])) {
|
||||
throw new coding_exception('Unknown plugin type root location', $plugintype);
|
||||
@ -2302,7 +2302,7 @@ class available_update_deployer {
|
||||
*/
|
||||
protected function component_writable($component) {
|
||||
|
||||
list($plugintype, $pluginname) = normalize_component($component);
|
||||
list($plugintype, $pluginname) = core_component::normalize_component($component);
|
||||
|
||||
$directory = core_component::get_plugin_directory($plugintype, $pluginname);
|
||||
|
||||
|
@ -95,7 +95,7 @@ EOD;
|
||||
* @return component_generator_base or rather an instance of the appropriate subclass.
|
||||
*/
|
||||
public function get_plugin_generator($component) {
|
||||
list($type, $plugin) = normalize_component($component);
|
||||
list($type, $plugin) = core_component::normalize_component($component);
|
||||
$cleancomponent = $type . '_' . $plugin;
|
||||
if ($cleancomponent != $component) {
|
||||
debugging("Please specify the component you want a generator for as " .
|
||||
|
@ -1164,7 +1164,7 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) {
|
||||
$plugin = 'core';
|
||||
}
|
||||
|
||||
list($plugintype, $pluginname) = normalize_component($plugin);
|
||||
list($plugintype, $pluginname) = core_component::normalize_component($plugin);
|
||||
$component = is_null($pluginname) ? $plugintype : $plugintype . '_' . $pluginname;
|
||||
|
||||
$backtrace = format_backtrace($backtrace, true);
|
||||
|
@ -523,7 +523,7 @@ class rating_manager {
|
||||
|
||||
// Get the item table name, the item id field, and the item user field for the given rating item
|
||||
// from the related component.
|
||||
list($type, $name) = normalize_component($options->component);
|
||||
list($type, $name) = core_component::normalize_component($options->component);
|
||||
$default = array(null, 'id', 'userid');
|
||||
list($itemtablename, $itemidcol, $itemuseridcol) = plugin_callback($type, $name, 'rating', 'get_item_fields', array($options), $default);
|
||||
|
||||
@ -928,7 +928,7 @@ class rating_manager {
|
||||
$pluginpermissionsarray = null;
|
||||
$defaultpluginpermissions = array('rate'=>false,'view'=>false,'viewany'=>false,'viewall'=>false);//deny by default
|
||||
if (!empty($component)) {
|
||||
list($type, $name) = normalize_component($component);
|
||||
list($type, $name) = core_component::normalize_component($component);
|
||||
$pluginpermissionsarray = plugin_callback($type, $name, 'rating', 'permissions', array($contextid, $component, $ratingarea), $defaultpluginpermissions);
|
||||
} else {
|
||||
$pluginpermissionsarray = $defaultpluginpermissions;
|
||||
@ -971,7 +971,7 @@ class rating_manager {
|
||||
throw new coding_exception('The rateduserid option is now a required option when checking rating validity');
|
||||
}
|
||||
|
||||
list($plugintype, $pluginname) = normalize_component($params['component']);
|
||||
list($plugintype, $pluginname) = core_component::normalize_component($params['component']);
|
||||
|
||||
//this looks for a function like forum_rating_validate() in mod_forum lib.php
|
||||
//wrapping the params array in another array as call_user_func_array() expands arrays into multiple arguments
|
||||
|
@ -149,7 +149,7 @@ try {
|
||||
|
||||
// Work out which component in Moodle we want (from the frankenstyle name)
|
||||
$componentdir = get_component_directory($componentname);
|
||||
list($type, $plugin) = normalize_component($componentname);
|
||||
list($type, $plugin) = core_component::normalize_component($componentname);
|
||||
|
||||
|
||||
// Call the component to check/update the feed and tell us the path to the cached file
|
||||
|
Loading…
x
Reference in New Issue
Block a user