public function BynderTagSearchService::searchTags in Bynder 8.3
Same name and namespace in other branches
- 8 src/Controller/BynderTagSearchService.php \Drupal\bynder\Controller\BynderTagSearchService::searchTags()
- 8.2 src/Controller/BynderTagSearchService.php \Drupal\bynder\Controller\BynderTagSearchService::searchTags()
- 4.0.x src/Controller/BynderTagSearchService.php \Drupal\bynder\Controller\BynderTagSearchService::searchTags()
Route callback for tags search.
1 string reference to 'BynderTagSearchService::searchTags'
File
- src/
Controller/ BynderTagSearchService.php, line 63
Class
- BynderTagSearchService
- Class BynderTagSearchService.
Namespace
Drupal\bynder\ControllerCode
public function searchTags(Request $request) {
$results = [];
$keyword = $request
->get('term');
try {
$results = array_map(function ($tag) {
return [
'id' => $tag['tag'],
'text' => $tag['tag'],
];
}, $this->bynder
->getTags([
'limit' => self::TAG_LIST_LIMIT,
'keyword' => $keyword,
'minCount' => 1,
]));
} catch (\Exception $e) {
(new TagSearchException($e
->getMessage()))
->logException()
->displayMessage();
return FALSE;
}
usort($results, function ($first, $second) {
return $first['text'] < $second['text'] ? -1 : 1;
});
$response['results'] = $results;
return new JsonResponse($response);
}