Pass typeahead ressource search as query param instead of URL part.

This hopefully fixes the 404 bugs, when putting an URL in the typeahead field...
This commit is contained in:
Jan Böhmer 2020-05-22 12:39:12 +02:00
parent 1a84bdc3a3
commit e6a3c41cee

View file

@ -46,6 +46,7 @@ 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;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
@ -59,12 +60,13 @@ use Symfony\Component\Serializer\Serializer;
class TypeaheadController extends AbstractController
{
/**
* @Route("/builtInResources/search/{query}", name="typeahead_builtInRessources", requirements={"query"= ".+"})
* @Route("/builtInResources/search", name="typeahead_builtInRessources")
*
* @return JsonResponse
*/
public function builtInResources(string $query, BuiltinAttachmentsFinder $finder)
public function builtInResources(Request $request, BuiltinAttachmentsFinder $finder)
{
$query = $request->get('query');
$array = $finder->find($query);
$normalizers = [