MDL-77105 core: Method to determine whether a plugin has monolog icons

This commit is contained in:
Jun Pataleta
2023-03-27 13:36:38 +08:00
parent 5898c3e5dd
commit 69948eda10
2 changed files with 33 additions and 0 deletions
+18
View File
@@ -1282,4 +1282,22 @@ $cache = '.var_export($cache, true).';
}
return $componentnames;
}
/**
* Checks for the presence of monologo icons within a plugin.
*
* Only checks monologo icons in PNG and SVG formats as they are
* formats that can have transparent background.
*
* @param string $plugintype The plugin type.
* @param string $pluginname The plugin name.
* @return bool True if the plugin has a monologo icon
*/
public static function has_monologo_icon(string $plugintype, string $pluginname): bool {
$plugindir = core_component::get_plugin_directory($plugintype, $pluginname);
if ($plugindir === null) {
return false;
}
return file_exists("$plugindir/pix/monologo.svg") || file_exists("$plugindir/pix/monologo.png");
}
}