Skip to content

Commit

Permalink
MDL-40220 use new core_component::normalize_component()
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 16, 2013
1 parent 1c74b26 commit 56da374
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion admin/tool/customlang/filter_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function definition() {
// 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';
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/customlang/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ protected static function dump_strings($lang, $component, $strings) {
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";
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/installaddon/classes/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function handle_remote_request(tool_installaddon_renderer $output, $reque
exit();
}

list($plugintype, $pluginname) = normalize_component($data->component);
list($plugintype, $pluginname) = core_component::normalize_component($data->component);

$plugintypepath = $this->get_plugintype_root($plugintype);

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/installaddon/classes/validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ protected function validate_version_php() {

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'],
Expand Down
2 changes: 1 addition & 1 deletion comment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function set_component($component) {
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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion course/dnduploadlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function __construct($course, $modnames = null) {
// 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.
}
Expand Down
2 changes: 1 addition & 1 deletion grade/grading/form/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function __construct(stdClass $context, $component, $area, $areaid) {
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;
Expand Down
4 changes: 2 additions & 2 deletions grade/grading/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function get_component() {
*/
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;
}

Expand Down Expand Up @@ -288,7 +288,7 @@ public function get_available_methods($includenone = true) {
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();
Expand Down
2 changes: 1 addition & 1 deletion lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion lib/messagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/outputfactories.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function standard_renderer_classname($component, $subtype = null) {
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 {
Expand Down
12 changes: 6 additions & 6 deletions lib/pluginlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -868,15 +868,15 @@ public static function standard_plugins_list($type) {
}

/**
* 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.
*
* @param string $component
* @return array
*/
protected function normalize_component($component) {
return normalize_component($component);
return core_component::normalize_component($component);
}

/**
Expand Down Expand Up @@ -1619,7 +1619,7 @@ protected function cron_notifications(array $changes) {
// 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)) {
Expand Down Expand Up @@ -1974,7 +1974,7 @@ public function deployment_impediments(available_update_info $info) {
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')) {
Expand Down Expand Up @@ -2033,7 +2033,7 @@ public function make_execution_widget(available_update_info $info, moodle_url $r

$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);
Expand Down Expand Up @@ -2302,7 +2302,7 @@ protected function generate_password() {
*/
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);

Expand Down
2 changes: 1 addition & 1 deletion lib/testing/generator/data_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function reset() {
* @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 " .
Expand Down
2 changes: 1 addition & 1 deletion lib/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions rating/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public function get_ratings($options) {

// 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);

Expand Down Expand Up @@ -928,7 +928,7 @@ public function get_plugin_permissions_array($contextid, $component, $ratingarea
$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;
Expand Down Expand Up @@ -971,7 +971,7 @@ public function check_rating_is_valid($params) {
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
Expand Down
2 changes: 1 addition & 1 deletion rss/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@

// 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
Expand Down

0 comments on commit 56da374

Please sign in to comment.