Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioMendolia committed Sep 10, 2023
1 parent dd082fb commit c5701a2
Show file tree
Hide file tree
Showing 36 changed files with 664 additions and 625 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"ext-exif": "*",
"ext-iconv": "*",
"ext-zip": "*",
"andanteproject/page-filter-form-bundle": "^1.0",
"doctrine/annotations": "^2.0",
"doctrine/doctrine-bundle": "^2.9",
"doctrine/doctrine-migrations-bundle": "^3.2",
Expand Down
72 changes: 70 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true],
Symfony\UX\Autocomplete\AutocompleteBundle::class => ['all' => true],
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
Andante\PageFilterFormBundle\AndantePageFilterFormBundle::class => ['all' => true],
];
6 changes: 5 additions & 1 deletion config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ security:
property: username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
pattern: ^/(_(profiler|wdt)|css|images|js|media)/
security: false
image_resolver:
pattern: ^/media/cache/resolve
security:
false
main:
lazy: true
provider: app_user_provider
Expand Down
2 changes: 2 additions & 0 deletions config/packages/twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ twig:
globals:
displayMode: "@app.display_mode_subscriber" #The id of your service

form_themes: ['bootstrap_5_layout.html.twig']

when@test:
twig:
strict_variables: true
60 changes: 0 additions & 60 deletions src/Command/RenameAuthorCommand.php

This file was deleted.

56 changes: 0 additions & 56 deletions src/Command/RenameSerieCommand.php

This file was deleted.

51 changes: 0 additions & 51 deletions src/Controller/AuthorController.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/Controller/AutocompleteGroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function index(Request $request, BookRepository $bookRepository, string $
'serie' => $bookRepository->getAllSeries()->getResult(),
'authors' => $bookRepository->getAllAuthors(),
'tags' => $bookRepository->getAllTags(),
'publisher' => $bookRepository->getAllPublisherss()->getResult(),
default => [],
};

Expand All @@ -41,7 +42,7 @@ public function index(Request $request, BookRepository $bookRepository, string $
}
$json['results'][] = ['value' => $item['item'], 'text' => $item['item']];
}
if (!$exactmatch && strlen($query) > 2) {
if (!$exactmatch && strlen($query) > 2 && $request->get('create', true) === true) {
$json['results'][] = ['value' => $query, 'text' => 'New: '.$query];
}

Expand Down
56 changes: 12 additions & 44 deletions src/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,36 @@

namespace App\Controller;

use Andante\PageFilterFormBundle\PageFilterFormTrait;
use App\Form\BookFilterType;
use App\Repository\BookRepository;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends AbstractController
{
#[Route('/{page}', name: 'app_homepage', requirements: ['page' => '\d+'])]
public function index(BookRepository $bookRepository, PaginatorInterface $paginator, int $page = 1): Response
{
$pagination = $paginator->paginate(
$bookRepository->getAllBooksQuery(),
$page,
18
);
use PageFilterFormTrait;

return $this->render('default/index.html.twig', [
'pagination' => $pagination,
'page' => $page,
]);
}

#[Route('/favorites/{page}', name: 'app_favorites', requirements: ['page' => '\d+'])]
public function favorites(BookRepository $bookRepository, PaginatorInterface $paginator, int $page = 1): Response
{
$pagination = $paginator->paginate(
$bookRepository->getFavoriteBooksQuery(),
$page,
18
);

return $this->render('default/index.html.twig', [
'pagination' => $pagination, 'page' => $page,
]);
}

#[Route('/finished/{read}/{page}', name: 'app_read', requirements: ['page' => '\d+'])]
public function finished(BookRepository $bookRepository, PaginatorInterface $paginator, int $read, int $page = 1): Response
#[Route('/{page}', name: 'app_homepage', requirements: ['page' => '\d+'])]
public function index(Request $request, BookRepository $bookRepository, PaginatorInterface $paginator, int $page = 1): Response
{
$pagination = $paginator->paginate(
$bookRepository->getBooksByReadStatus((bool) $read),
$page,
18
);
$qb = $bookRepository->getAllBooksQueryBuilder();

return $this->render('default/index.html.twig', [
'pagination' => $pagination, 'page' => $page,
]);
}
$form = $this->createAndHandleFilter(BookFilterType::class, $qb, $request);

#[Route('/unverified/{page}', name: 'app_unverified', requirements: ['page' => '\d+'])]
public function unverified(BookRepository $bookRepository, PaginatorInterface $paginator, int $page = 1): Response
{
$pagination = $paginator->paginate(
$bookRepository->getUnverifiedBooksQuery(),
$qb->getQuery(),
$page,
18
);

return $this->render('default/index.html.twig', [
'pagination' => $pagination, 'page' => $page,
'pagination' => $pagination,
'page' => $page,
'form' => $form->createView(),
]);
}
}
Loading

0 comments on commit c5701a2

Please sign in to comment.