pages works
This commit is contained in:
parent
48bcf42e7d
commit
ad85898786
@ -8,7 +8,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
Use App\Utils;
|
use App\Utils;
|
||||||
|
|
||||||
class SearchController extends AbstractController
|
class SearchController extends AbstractController
|
||||||
{
|
{
|
||||||
@ -37,7 +37,8 @@ class SearchController extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getEmojiName(string | null $emoji) : string | null {
|
private static function getEmojiName(string | null $emoji): string | null
|
||||||
|
{
|
||||||
return match ($emoji) {
|
return match ($emoji) {
|
||||||
"🍎" => "apple",
|
"🍎" => "apple",
|
||||||
"🍐" => "pear",
|
"🍐" => "pear",
|
||||||
@ -66,14 +67,14 @@ class SearchController extends AbstractController
|
|||||||
$fruit = $request->query->get('fruit');
|
$fruit = $request->query->get('fruit');
|
||||||
$user_query = $request->query->get('q');
|
$user_query = $request->query->get('q');
|
||||||
|
|
||||||
$fruit_emoji = SearchController::getEmojiName($fruit);
|
$fruit_name = SearchController::getEmojiName($fruit);
|
||||||
if ($fruit_emoji == null) {
|
if ($fruit_name == null) {
|
||||||
// We do not support requests without a fruit or with an invalid one
|
// We do not support requests without a fruit or with an invalid one
|
||||||
// Redirect to the homepage in this case
|
// Redirect to the homepage in this case
|
||||||
return $this->redirect('/');
|
return $this->redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$fruit_query = $user_query . " " . $fruit_emoji;
|
$fruit_query = $user_query . " " . $fruit_name;
|
||||||
$page_str = strval($page);
|
$page_str = strval($page);
|
||||||
$response = Utils::makeRequest("GET", "/database/search", [
|
$response = Utils::makeRequest("GET", "/database/search", [
|
||||||
"q" => $fruit_query,
|
"q" => $fruit_query,
|
||||||
@ -109,7 +110,7 @@ class SearchController extends AbstractController
|
|||||||
return $this->render('search/search.html.twig', [
|
return $this->render('search/search.html.twig', [
|
||||||
'controller_name' => 'SearchController',
|
'controller_name' => 'SearchController',
|
||||||
'query' => $user_query,
|
'query' => $user_query,
|
||||||
'fruit_emoji' => $fruit_emoji,
|
'fruit_emoji' => $fruit,
|
||||||
'fruit_name' => SearchController::getEmojiName($fruit),
|
'fruit_name' => SearchController::getEmojiName($fruit),
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
'all_page' => $response["pagination"]["pages"],
|
'all_page' => $response["pagination"]["pages"],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user