Added autocomplete for part tags input.

This commit is contained in:
Jan Böhmer 2019-11-01 23:07:31 +01:00
parent bddd5b758a
commit 7a5a2f65f9
4 changed files with 153 additions and 5 deletions

View file

@ -24,6 +24,7 @@ namespace App\Controller;
use App\Services\Attachments\BuiltinAttachmentsFinder;
use App\Services\TagFinder;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
@ -47,6 +48,24 @@ class TypeaheadController extends AbstractController
$array = $finder->find($query);
$normalizers = [
new ObjectNormalizer()
];
$encoders = [
new JsonEncoder()
];
$serializer = new Serializer($normalizers, $encoders);
$data = $serializer->serialize($array, 'json');
return new JsonResponse($data, 200, [], true);
}
/**
* @Route("/tags/search/{query}", name="typeahead_tags", requirements={"query"= ".+"})
*/
public function tags(string $query, TagFinder $finder)
{
$array = $finder->searchTags($query);
$normalizers = [
new ObjectNormalizer()
];