diff --git a/core/includes/common.inc b/core/includes/common.inc index a3b1910325dd3749d51f5596eb18465de6733682..fa9ec08d47c0a7a171d2164b411e7e3406988f26 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4683,32 +4683,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 the 'weight' element. - * - * Note that the sorting is by the 'weight' array element, not by the render - * element property '#weight'. - * - * Callback for uasort() used in various functions. - * - * @param $a - * First item for comparison. The compared items should be associative arrays - * that optionally include a 'weight' element. For items without a 'weight' - * element, a default value of 0 will be used. - * @param $b - * Second item for comparison. - * - * @return int - * The comparison result for uasort(). - * - * @see \Drupal\Component\Utility\SortArray::sortByWeightElement() - * - * @deprecated as of Drupal 8.0. Use SortArray::sortByWeightElement() instead. - */ -function drupal_sort_weight($a, $b) { - return SortArray::sortByWeightElement((array) $a, (array) $b); -} - /** * Sorts a structured array by 'title' key (no # prefix). * @@ -5138,7 +5112,7 @@ function drupal_get_updaters() { if (!isset($updaters)) { $updaters = \Drupal::moduleHandler()->invokeAll('updater_info'); drupal_alter('updater_info', $updaters); - uasort($updaters, 'drupal_sort_weight'); + uasort($updaters, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); } return $updaters; } @@ -5158,7 +5132,7 @@ function drupal_get_filetransfer_info() { if (!isset($info)) { $info = \Drupal::moduleHandler()->invokeAll('filetransfer_info'); drupal_alter('filetransfer_info', $info); - uasort($info, 'drupal_sort_weight'); + uasort($info, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); } return $info; } diff --git a/core/includes/update.inc b/core/includes/update.inc index e8ff9bb61b8aea79f2f33b8bef2322f05c9106cf..fe74fe00bc143e109d815d0d267962c2590c1c98 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -1067,7 +1067,7 @@ function update_resolve_dependencies($starting_updates) { // Perform the depth-first search and sort on the results. $graph_object = new Graph($graph); $graph = $graph_object->searchAndSort(); - uasort($graph, 'drupal_sort_weight'); + uasort($graph, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); foreach ($graph as $function => &$data) { $module = $data['module']; diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index b169e2feca85074f62562a11aa60d5f21ffd6b24..ef3ec4335c9085af143008e95d89be080c1c2897 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -160,7 +160,7 @@ public function buildOperations(EntityInterface $entity) { // Retrieve and sort operations. $operations = $this->getOperations($entity); $this->moduleHandler()->alter('entity_operation', $operations, $entity); - uasort($operations, 'drupal_sort_weight'); + uasort($operations, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); $build = array( '#type' => 'operations', '#links' => $operations, diff --git a/core/lib/Drupal/Core/Field/WidgetPluginManager.php b/core/lib/Drupal/Core/Field/WidgetPluginManager.php index 0a789866e351d505c99ee468289713efa427c4f6..8d010e76ccc8d4f6ed1800a05c0f8abbdeafa4ed 100644 --- a/core/lib/Drupal/Core/Field/WidgetPluginManager.php +++ b/core/lib/Drupal/Core/Field/WidgetPluginManager.php @@ -171,7 +171,7 @@ public function getOptions($field_type = NULL) { $options = array(); $field_types = $this->fieldTypeManager->getDefinitions(); $widget_types = $this->getDefinitions(); - uasort($widget_types, 'drupal_sort_weight'); + uasort($widget_types, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); foreach ($widget_types as $name => $widget_type) { foreach ($widget_type['field_types'] as $widget_field_type) { // Check that the field type exists. diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index d1dc72145f11ff16e2f30263a946ba7b6b6e4e5e..12fda9cf7ffca847cc7396192d5196f47e847f6d 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -75,7 +75,7 @@ function testList() { $actual_operations = $controller->getOperations($entity); // Sort the operations to normalize link order. - uasort($actual_operations, 'drupal_sort_weight'); + uasort($actual_operations, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); $this->assertIdentical($expected_operations, $actual_operations, 'The operations are identical.'); // Test buildHeader() method. @@ -148,7 +148,7 @@ function testList() { $actual_operations = $controller->getOperations($entity); // Sort the operations to normalize link order. - uasort($actual_operations, 'drupal_sort_weight'); + uasort($actual_operations, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); $this->assertIdentical($expected_operations, $actual_operations, 'The operations are identical.'); } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php index 391f0f069f852ba16d33889900d517ca3df36a6f..8f3738414cf1348a4ec5bedf7153e76d11979d49 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php @@ -61,7 +61,7 @@ public function getInstance(array $options) { $selection_handler_groups = $this->getSelectionGroups($target_entity_type); // Sort the selection plugins by weight and select the best match. - uasort($selection_handler_groups[$selection_handler], 'drupal_sort_weight'); + uasort($selection_handler_groups[$selection_handler], array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); end($selection_handler_groups[$selection_handler]); $plugin_id = key($selection_handler_groups[$selection_handler]); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php index 1bb74a53dac554cb073e56c2cb49c637067f94ab..334914b63dcc6c291c910999433bf67b64ecf57b 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php @@ -240,7 +240,7 @@ public function reduceOrder($array, $a) { $array[] = $a['name']; } if (!empty($a['children'])) { - uasort($a['children'], 'drupal_sort_weight'); + uasort($a['children'], array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); $array = array_merge($array, array_reduce($a['children'], array($this, 'reduceOrder'))); } return $array; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php index 9bd534d656ba9ec06d092eb190dad23c30b45125..b680223eca836db20d66714f66ae71d9a43e41dc 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php @@ -370,7 +370,7 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $ */ public function submitForm(array &$form, array &$form_state) { // Sort term order based on weight. - uasort($form_state['values']['terms'], 'drupal_sort_weight'); + uasort($form_state['values']['terms'], array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); $vocabulary = $form_state['taxonomy']['vocabulary']; // Update the current hierarchy type as we go. diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php index 0622d86151479296603adaeb38410b592c4a8f7e..9e94d24c491a613f50bc05dc722178284e57ab94 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php @@ -665,7 +665,7 @@ protected function buildGroupValidate($form, &$form_state) { */ protected function buildGroupSubmit($form, &$form_state) { $groups = array(); - uasort($form_state['values']['options']['group_info']['group_items'], 'drupal_sort_weight'); + uasort($form_state['values']['options']['group_info']['group_items'], array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); // Filter out removed items. // Start from 1 to avoid problems with #default_value in the widget.