Added book search.
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Entity\Book;
|
||||
use App\Entity\File;
|
||||
use App\Form\BookType;
|
||||
use App\Form\FileType;
|
||||
use App\Form\SearchType;
|
||||
use App\Repository\BookRepository;
|
||||
use App\Repository\FileRepository;
|
||||
use App\Service\FileService;
|
||||
@@ -79,6 +80,21 @@ class BookController extends AbstractController
|
||||
return new JsonResponse($bookFinder->search($phrase));
|
||||
}
|
||||
|
||||
#[Route('/search/', name: 'app_book_search_book', methods: ['GET', 'POST'])]
|
||||
public function searchBook(BookRepository $bookRepository, Request $request): Response
|
||||
{
|
||||
$searchForm = $this->createForm(SearchType::class);
|
||||
$searchForm->handleRequest($request);
|
||||
$books = [];
|
||||
if ($searchForm->isSubmitted() && $searchForm->isValid()) {
|
||||
$books = $bookRepository->findByTitle($searchForm->get('search')->getData());
|
||||
}
|
||||
return $this->renderForm('book/search.html.twig', [
|
||||
'books' => $books,
|
||||
'searchTerm' => $searchForm->get('search')->getData()
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/info/{urlInBase64}', name: 'app_book_info', methods: ['GET'])]
|
||||
public function info(string $urlInBase64): JsonResponse
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user