Skip to content

Commit

Permalink
MDL-41100 libraries: Deprecating get_plugin_list_with_file
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Aug 9, 2013
1 parent d26ec8a commit d0cac8b
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 30 deletions.
10 changes: 5 additions & 5 deletions cache/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function add_store_instance($name, $plugin, array $configuration = array(
}
$class = 'cachestore_'.$plugin;
if (!class_exists($class)) {
$plugins = get_plugin_list_with_file('cachestore', 'lib.php');
$plugins = core_component::get_plugin_list_with_file('cachestore', 'lib.php');
if (!array_key_exists($plugin, $plugins)) {
throw new cache_exception('Invalid plugin name specified. The plugin does not exist or is not valid.');
}
Expand Down Expand Up @@ -204,7 +204,7 @@ public function add_lock_instance($name, $plugin, $configuration = array()) {
}
$class = 'cachelock_'.$plugin;
if (!class_exists($class)) {
$plugins = get_plugin_list_with_file('cachelock', 'lib.php');
$plugins = core_component::get_plugin_list_with_file('cachelock', 'lib.php');
if (!array_key_exists($plugin, $plugins)) {
throw new cache_exception('Invalid lock name specified. The plugin does not exist or is not valid.');
}
Expand Down Expand Up @@ -315,7 +315,7 @@ public function edit_store_instance($name, $plugin, $configuration) {
if (!array_key_exists($name, $this->configstores)) {
throw new cache_exception('The requested instance does not exist.');
}
$plugins = get_plugin_list_with_file('cachestore', 'lib.php');
$plugins = core_component::get_plugin_list_with_file('cachestore', 'lib.php');
if (!array_key_exists($plugin, $plugins)) {
throw new cache_exception('Invalid plugin name specified. The plugin either does not exist or is not valid.');
}
Expand Down Expand Up @@ -523,7 +523,7 @@ protected static function locate_definitions($coreonly = false) {
if (!$coreonly) {
$plugintypes = core_component::get_plugin_types();
foreach ($plugintypes as $type => $location) {
$plugins = get_plugin_list_with_file($type, 'db/caches.php');
$plugins = core_component::get_plugin_list_with_file($type, 'db/caches.php');
foreach ($plugins as $plugin => $filepath) {
$component = clean_param($type.'_'.$plugin, PARAM_COMPONENT); // Standardised plugin name.
$files[$component] = $filepath;
Expand Down Expand Up @@ -738,7 +738,7 @@ public static function get_store_instance_summaries() {
*/
public static function get_store_plugin_summaries() {
$return = array();
$plugins = get_plugin_list_with_file('cachestore', 'lib.php', true);
$plugins = core_component::get_plugin_list_with_file('cachestore', 'lib.php', true);
foreach ($plugins as $plugin => $path) {
$class = 'cachestore_'.$plugin;
$return[$plugin] = array(
Expand Down
2 changes: 1 addition & 1 deletion cache/testperformance.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
$strtested = new lang_string('tested', 'cache');
$strnotready = new lang_string('storenotready', 'cache');

foreach (get_plugin_list_with_file('cachestore', 'lib.php', true) as $plugin => $path) {
foreach (core_component::get_plugin_list_with_file('cachestore', 'lib.php', true) as $plugin => $path) {

$class = 'cachestore_'.$plugin;
$plugin = get_string('pluginname', 'cachestore_'.$plugin);
Expand Down
18 changes: 18 additions & 0 deletions lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4401,3 +4401,21 @@ function get_related_contexts_string(context $context) {
function isediting() {
throw new coding_exception('isediting() can not be used any more, please use $PAGE->user_is_editing() instead.');
}

/**
* Get a list of all the plugins of a given type that contain a particular file.
*
* @param string $plugintype the type of plugin, e.g. 'mod' or 'report'.
* @param string $file the name of file that must be present in the plugin.
* (e.g. 'view.php', 'db/install.xml').
* @param bool $include if true (default false), the file will be include_once-ed if found.
* @return array with plugin name as keys (e.g. 'forum', 'courselist') and the path
* to the file relative to dirroot as value (e.g. "$CFG->dirroot/mod/forum/view.php").
* @deprecated since 2.6
* @see core_component::get_plugin_list_with_file()
*/
function get_plugin_list_with_file($plugintype, $file, $include = false) {
debugging('get_plugin_list_with_file() is deprecated, please use core_component::get_plugin_list_with_file() instead.',
DEBUG_DEVELOPER);
return core_component::get_plugin_list_with_file($plugintype, $file, $include);
}
17 changes: 2 additions & 15 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -8154,20 +8154,6 @@ function is_valid_plugin_name($name) {
return core_component::is_valid_plugin_name('tool', $name);
}

/**
* Get a list of all the plugins of a given type that contain a particular file.
*
* @param string $plugintype the type of plugin, e.g. 'mod' or 'report'.
* @param string $file the name of file that must be present in the plugin.
* (e.g. 'view.php', 'db/install.xml').
* @param bool $include if true (default false), the file will be include_once-ed if found.
* @return array with plugin name as keys (e.g. 'forum', 'courselist') and the path
* to the file relative to dirroot as value (e.g. "$CFG->dirroot/mod/forum/view.php").
*/
function get_plugin_list_with_file($plugintype, $file, $include = false) {
return core_component::get_plugin_list_with_file($plugintype, $file, $include);
}

/**
* Get a list of all the plugins of a given type that define a certain API function
* in a certain file. The plugin component names and function names are returned.
Expand All @@ -8183,7 +8169,8 @@ function get_plugin_list_with_file($plugintype, $file, $include = false) {
*/
function get_plugin_list_with_function($plugintype, $function, $file = 'lib.php') {
$pluginfunctions = array();
foreach (get_plugin_list_with_file($plugintype, $file, true) as $plugin => $notused) {
$pluginswithfile = core_component::get_plugin_list_with_file($plugintype, $file, true);
foreach ($pluginswithfile as $plugin => $notused) {
$fullfunction = $plugintype . '_' . $plugin . '_' . $function;

if (function_exists($fullfunction)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ public function initialise() {
}

// Give the local plugins a chance to include some navigation if they want.
foreach (get_plugin_list_with_file('local', 'lib.php', true) as $plugin => $file) {
foreach (core_component::get_plugin_list_with_file('local', 'lib.php', true) as $plugin => $file) {
$function = "local_{$plugin}_extends_navigation";
$oldfunction = "{$plugin}_extends_navigation";
if (function_exists($function)) {
Expand Down
8 changes: 4 additions & 4 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ information provided here is intended especially for developers.
=== 2.6 ===

* Use new methods from core_component class instead of get_core_subsystems(), get_plugin_types(),
get_plugin_list(), get_plugin_list_with_class(), get_plugin_directory(), normalize_component()
and get_component_directory(). The names of the new methods are exactly the same, the only differences
are that core_component::get_plugin_types() now always returns full paths and
core_component::get_plugin_list() does not accept empty parameter any more.
get_plugin_list(), get_plugin_list_with_class(), get_plugin_directory(), normalize_component(),
get_component_directory() and get_plugin_list_with_file(). The names of the new methods are
exactly the same, the only differences are that core_component::get_plugin_types() now always returns
full paths and core_component::get_plugin_list() does not accept empty parameter any more.
* Use core_text::* instead of textlib:: and also core_collator::* instead of collatorlib::*.
* Use new function moodleform::mock_submit() to simulate form submission in unit tests (backported).
* New $CFG->localcachedir setting useful for cluster nodes. Admins have to update X-Sendfile aliases if used.
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public static function add_admin_assign_plugin_settings($subtype,
$module) {
global $CFG;

$plugins = get_plugin_list_with_file($subtype, 'settings.php', false);
$plugins = core_component::get_plugin_list_with_file($subtype, 'settings.php', false);
$pluginsbyname = array();
foreach ($plugins as $plugin => $plugindir) {
$pluginname = get_string('pluginname', $subtype . '_'.$plugin);
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

// First get a list of quiz reports with there own settings pages. If there none,
// we use a simpler overall menu structure.
$reports = get_plugin_list_with_file('quiz', 'settings.php', false);
$reports = core_component::get_plugin_list_with_file('quiz', 'settings.php', false);
$reportsbyname = array();
foreach ($reports as $report => $reportdir) {
$strreportname = get_string($report . 'report', 'quiz_'.$report);
Expand All @@ -42,7 +42,7 @@

// First get a list of quiz reports with there own settings pages. If there none,
// we use a simpler overall menu structure.
$rules = get_plugin_list_with_file('quizaccess', 'settings.php', false);
$rules = core_component::get_plugin_list_with_file('quizaccess', 'settings.php', false);
$rulesbyname = array();
foreach ($rules as $rule => $ruledir) {
$strrulename = get_string('pluginname', 'quizaccess_' . $rule);
Expand Down
2 changes: 1 addition & 1 deletion mod/workshop/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static function available_strategies_list() {
*/
public static function available_evaluators_list() {
$evals = array();
foreach (get_plugin_list_with_file('workshopeval', 'lib.php', false) as $eval => $evalpath) {
foreach (core_component::get_plugin_list_with_file('workshopeval', 'lib.php', false) as $eval => $evalpath) {
$evals[$eval] = get_string('pluginname', 'workshopeval_' . $eval);
}
return $evals;
Expand Down

0 comments on commit d0cac8b

Please sign in to comment.