if ($component === 'moodle' or $component === 'core') {
switch ($contextlevel) {
- // TODO: this should probably use context level names instead
+ // TODO MDL-46123: this should probably use context level names instead
case CONTEXT_SYSTEM: return get_string('coresystem');
case CONTEXT_USER: return get_string('users');
case CONTEXT_COURSECAT: return get_string('categories');
}
switch ($type) {
- // TODO: this is really hacky, anyway it should be probably moved to lib/pluginlib.php
+ // TODO MDL-46123: this is really hacky and should be improved.
case 'quiz': return get_string($name.':componentname', $component);// insane hack!!!
case 'repository': return get_string('repository', 'repository').': '.get_string('pluginname', $component);
case 'gradeimport': return get_string('gradeimport', 'grades').': '.get_string('pluginname', $component);
return true;
}
}
-
-/**
- * Legacy collatorlib.
- * @deprecated since 2.6, use core_collator:: instead.
- */
-class collatorlib extends core_collator {
-}
}
return implode(' ', $words);
}
-}
-
-/**
- * Legacy tectlib.
- * @deprecated since 2.6, use core_text:: instead.
- */
-class textlib extends core_text {
- /**
- * Locale aware sorting, the key associations are kept, values are sorted alphabetically.
- *
- * @param array $arr array to be sorted (reference)
- * @param int $sortflag One of Collator::SORT_REGULAR, Collator::SORT_NUMERIC, Collator::SORT_STRING
- * @return void modifies parameter
- */
- public static function asort(array &$arr, $sortflag = null) {
- debugging('textlib::asort has been superseeded by collatorlib::asort please upgrade your code to use that', DEBUG_DEVELOPER);
- collatorlib::asort($arr, $sortflag);
- }
}
\ No newline at end of file
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains mappings for classes that have been renamed so that they meet the requirements of the autoloader.
+ *
+ * Renaming isn't always the recommended approach, but can provide benefit in situations where we've already got a
+ * close structure, OR where lots of classes get included and not necessarily used, or checked for often.
+ *
+ * When renaming a class delete the original class and add an entry to the db/renamedclasses.php directory for that
+ * component.
+ * This way we don't need to keep around old classes, instead creating aliases only when required.
+ * One big advantage to this method is that we provide consistent debugging for renamed classes when they are used.
+ *
+ * @package core
+ * @copyright 2014 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+// Like other files in the db directory this file uses an array.
+// The old class name is the key, the new class name is the value.
+// The array must be called $renamedclasses.
+$renamedclasses = array(
+
+ // Deprecated in 2.6.
+ // TODO MDL-46124: Remove textlib. collatorlib, plugin_manager, and plugininfo base in 2.9.
+ 'textlib' => 'core_text',
+ 'collatorlib' => 'core_collator',
+ 'plugin_manager' => 'core_plugin_manager',
+ 'plugininfo_base' => 'core\plugininfo\base'
+
+);
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
* Moodle. It is mainly used by the plugins management admin page and the
* plugins check page during the upgrade.
*
+ * @todo MDL-46122 This file will be removed in 2.9
* @package core
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
defined('MOODLE_INTERNAL') || die();
-
-/**
- * @deprecated since 2.6 - use core_plugin_manager instead.
- */
-class plugin_manager extends core_plugin_manager {
- // BC only.
- public static function instance() {
- return core_plugin_manager::instance();
- }
-}
-
-/**
- * @deprecated since 2.6 - use \core\plugininfo\base instead.
- */
-class plugininfo_base extends \core\plugininfo\base {
- // BC only.
-}
-
+debugging('lib/pluginlib.php has been deprecated, the classes that used to exist are now autoloaded. Please removed ' .
+ 'any calls to include or require this file.', DEBUG_DEVELOPER);
\ No newline at end of file
* @copyright 2011 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class core_collator_testcase extends basic_testcase {
+class core_collator_testcase extends advanced_testcase {
/**
* @var string The initial lang, stored because we change it during testing
public function test_legacy_collatorlib() {
$arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc');
$result = collatorlib::asort($arr);
+ $this->assertDebuggingCalled(null, null, 'This fails if any other test uses the deprecated collatorlib class.');
$this->assertSame(array('aa', 'ab', 'cc'), array_values($arr));
$this->assertSame(array(1, 'b', 0), array_keys($arr));
$this->assertTrue($result);
public function test_deprecated_textlib() {
$this->assertSame(textlib::strtolower('HUH'), core_text::strtolower('HUH'));
+ $this->assertDebuggingCalled(null, null, 'This fails if any other test uses the deprecated textlib class.');
}
/**
foreach ($lines as $line) {
$nlinecounter++;
- $line = textlib::convert($line, 'windows-1252', 'utf-8');
+ $line = core_text::convert($line, 'windows-1252', 'utf-8');
// Processing multiples lines strings.
if (isset($questiontext) and is_string($questiontext)) {