From dc15bf2eb231238b601d692da5f59d1b00be20a8 Mon Sep 17 00:00:00 2001 From: webchick Date: Mon, 24 Mar 2014 07:44:46 -0700 Subject: [PATCH] Issue #2216565 by ianthomas_uk: Remove wrappers for SortArray. --- core/includes/common.inc | 65 ------------------- .../lib/Drupal/shortcut/Form/SetCustomize.php | 2 +- .../system/Controller/AdminController.php | 2 +- .../Drupal/system/Form/ModulesListForm.php | 2 +- core/modules/toolbar/toolbar.module | 2 +- 5 files changed, 4 insertions(+), 69 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index e6cc3235bf5..2def62d056e 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4461,50 +4461,6 @@ function drupal_render_cid_create($elements) { return FALSE; } -/** - * Sorts a structured array by '#weight' property. - * - * Callback for uasort() within element_children(). - * - * @param $a - * First item for comparison. The compared items should be associative arrays - * that optionally include a '#weight' key. - * @param $b - * Second item for comparison. - * - * @return int - * The comparison result for uasort(). - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use \Drupal\Component\Utility\SortArray::sortByWeightProperty(). - */ -function element_sort($a, $b) { - return SortArray::sortByWeightProperty($a, $b); -} - -/** - * Sorts a structured array by '#title' property. - * - * Callback for uasort() within: - * - system_modules() - * - theme_simpletest_test_table() - * - * @param $a - * First item for comparison. The compared items should be associative arrays - * that optionally include a '#title' key. - * @param $b - * Second item for comparison. - * - * @return int - * The comparison result for uasort(). - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use \Drupal\Component\Utility\SortArray::sortByTitleProperty(). - */ -function element_sort_by_title($a, $b) { - return SortArray::sortByTitleProperty($a, $b); -} - /** * Retrieves the default properties for the defined element type. * @@ -4546,27 +4502,6 @@ function element_info_property($type, $property_name, $default = NULL) { return (($info = element_info($type)) && array_key_exists($property_name, $info)) ? $info[$property_name] : $default; } -/** - * Sorts a structured array by 'title' key (no # prefix). - * - * Callback for uasort() within system_admin_index(). - * - * @param $a - * First item for comparison. The compared items should be associative arrays - * that optionally include a 'title' key. - * @param $b - * Second item for comparison. - * - * @return int - * The comparison result for uasort(). - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use \Drupal\Component\Utility\SortArray::sortByTitleElement(). - */ -function drupal_sort_title($a, $b) { - return SortArray::sortByTitleElement($a, $b); -} - /** * Checks if the key is a property. * diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php index 37f204147ec..4432a72688b 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php @@ -74,7 +74,7 @@ class SetCustomize extends EntityFormController { ); } // Sort the list so the output is ordered by weight. - uasort($form['shortcuts']['links'], 'element_sort'); + uasort($form['shortcuts']['links'], array('\Drupal\Component\Utility\SortArray', 'sortByWeightProperty')); return $form; } diff --git a/core/modules/system/lib/Drupal/system/Controller/AdminController.php b/core/modules/system/lib/Drupal/system/Controller/AdminController.php index f1e231f18c6..7445d52b143 100644 --- a/core/modules/system/lib/Drupal/system/Controller/AdminController.php +++ b/core/modules/system/lib/Drupal/system/Controller/AdminController.php @@ -34,7 +34,7 @@ class AdminController extends ControllerBase { // Only display a section if there are any available tasks. if ($admin_tasks = system_get_module_admin_tasks($module, $info->info)) { // Sort links by title. - uasort($admin_tasks, 'drupal_sort_title'); + uasort($admin_tasks, array('\Drupal\Component\Utility\SortArray', 'sortByTitleElement')); // Move 'Configure permissions' links to the bottom of each section. $permission_key = "user.admin.people.permissions.$module"; if (isset($admin_tasks[$permission_key])) { diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php index 7b5d257b6ba..b3f9e94e530 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php @@ -160,7 +160,7 @@ class ModulesListForm extends FormBase { } // Lastly, sort all packages by title. - uasort($form['modules'], 'element_sort_by_title'); + uasort($form['modules'], array('\Drupal\Component\Utility\SortArray', 'sortByTitleProperty')); $form['#attached']['library'][] = 'system/drupal.system.modules'; $form['actions'] = array('#type' => 'actions'); diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 67b61fdd01e..3e54dd5afc7 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -196,7 +196,7 @@ function toolbar_pre_render($element) { // Allow for altering of hook_toolbar(). \Drupal::moduleHandler()->alter('toolbar', $items); // Sort the children. - uasort($items, 'element_sort'); + uasort($items, array('\Drupal\Component\Utility\SortArray', 'sortByWeightProperty')); // Merge in the original toolbar values. $element = array_merge($element, $items);