From 6c8d082611c82ae53b10c0d3a169123a9fc9518c Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Fri, 9 May 2014 11:23:10 +0100 Subject: [PATCH] Issue #2254777 by m1r1k: Block category autocomplete does not work. --- .../block/Controller/CategoryAutocompleteController.php | 2 +- .../tests/Drupal/block/Tests/CategoryAutocompleteTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php b/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php index 1b611471c0..0c35e82c05 100644 --- a/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php +++ b/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php @@ -59,7 +59,7 @@ public function autocomplete(Request $request) { $matches = array(); foreach ($this->blockManager->getCategories() as $category) { if (stripos($category, $typed_category) === 0) { - $matches[$category] = String::checkPlain($category); + $matches[] = array('value' => $category, 'label' => String::checkPlain($category)); } } return new JsonResponse($matches); diff --git a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php index 29d75d0ff8..26bd6b9151 100644 --- a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php @@ -59,8 +59,8 @@ public function setUp() { */ public function testAutocompleteSuggestions($string, $suggestions) { $suggestions = array_map(function ($suggestion) { - return String::checkPlain($suggestion); - }, array_combine($suggestions, $suggestions)); + return array('value' => $suggestion, 'label' => String::checkPlain($suggestion)); + }, $suggestions); $result = $this->autocompleteController->autocomplete(new Request(array('q' => $string))); $this->assertSame($suggestions, json_decode($result->getContent(), TRUE)); } -- GitLab