Skip to content

Commit

Permalink
Bugfix optional type argument and clean up code
Browse files Browse the repository at this point in the history
Bug was introduced in d94d594
  • Loading branch information
Adrian Perez committed Jun 2, 2021
1 parent e491654 commit eb906ed
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions externallib.php
Expand Up @@ -42,10 +42,10 @@ class local_pluginsfetcher_external extends external_api {
*/
public static function get_information_parameters() {
return new external_function_parameters(
array(
'type' => new external_value(PARAM_TEXT, 'The type of plugins to retrieve (optional).', false, null),
'contribonly' => new external_value(PARAM_INT, 'Get only additional installed (optional)..', false, null)
)
array(
'type' => new external_value(PARAM_TEXT, 'The type of plugins to retrieve (optional).', false, null),
'contribonly' => new external_value(PARAM_INT, 'Get only additional installed (optional)..', false, null)
)
);
}

Expand All @@ -59,15 +59,15 @@ public static function get_information_parameters() {
* @throws invalid_parameter_exception
* @throws required_capability_exception
*/
public static function get_information(string $type, ?int $contribonly) {
public static function get_information(?string $type, ?int $contribonly) {
$syscontext = context_system::instance();
require_capability('moodle/site:config', $syscontext);

$params = self::validate_parameters(self::get_information_parameters(),
array(
'type' => $type,
'contribonly' => $contribonly
)
array(
'type' => $type,
'contribonly' => $contribonly
)
);

$pluginman = core_plugin_manager::instance();
Expand Down Expand Up @@ -100,14 +100,14 @@ public static function get_information(string $type, ?int $contribonly) {
*/
public static function get_information_returns() {
return new external_multiple_structure(
new external_single_structure(
array(
'type' => new external_value(PARAM_TEXT, 'The type'),
'name' => new external_value(PARAM_TEXT, 'The name'),
'versiondb' => new external_value(PARAM_INT, 'The installed version'),
'release' => new external_value(PARAM_TEXT, 'The installed release')
), 'plugins'
)
new external_single_structure(
array(
'type' => new external_value(PARAM_TEXT, 'The type'),
'name' => new external_value(PARAM_TEXT, 'The name'),
'versiondb' => new external_value(PARAM_INT, 'The installed version'),
'release' => new external_value(PARAM_TEXT, 'The installed release')
), 'plugins'
)
);
}

Expand All @@ -126,7 +126,7 @@ protected static function get_plugins_by_parameters(object $pluginman, $type = n
foreach ($plugininfo as $plugintype => $pluginnames) {
foreach ($pluginnames as $pluginname => $plugin) {
if ($contribonly || ($plugin->type == $type && !$plugin->is_standard()) ||
(is_null($type) && !$plugin->is_standard())) {
(is_null($type) && !$plugin->is_standard())) {
$key = $plugintype . '_' . $pluginname;
$plugins[$key] = $plugin;
}
Expand Down

0 comments on commit eb906ed

Please sign in to comment.