feat: manually mark teamer as viewed

This commit is contained in:
Björn Fromme
2024-07-15 14:30:26 +02:00
parent e07238b983
commit dcaf338da8
3 changed files with 26 additions and 11 deletions
@@ -2,8 +2,11 @@
namespace App\Controller\Administrative\Teamer;
use App\Entity\Teamer;
use App\Htmx\HxRedirectResponse;
use App\Repository\TeamerRepository;
use App\Service\Common\TeamerFilterHandler;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -16,7 +19,8 @@ class IndexController extends AbstractController
public function __construct(
protected readonly TeamerFilterHandler $filterHandler,
private readonly TeamerRepository $teamerRepository,
private readonly PaginatorInterface $paginator
private readonly PaginatorInterface $paginator,
private readonly EntityManagerInterface $entityManager
) {
}
@@ -25,11 +29,10 @@ class IndexController extends AbstractController
public function index(Request $request): Response
{
$filterDto = $this->filterHandler->getFilterSettings();
$requestedSorting = $request->query->get('sort');
$query = $this
->teamerRepository
->getListQuery($filterDto, $requestedSorting)
->getListQuery($filterDto)
;
$pagination = $this->paginator->paginate(
@@ -43,4 +46,14 @@ class IndexController extends AbstractController
'filterDto' => $filterDto,
]);
}
#[Route('/administrative/teamer/viewed/{uuid}', name: 'app_administrative_teamer_viewed', methods: ['POST'])]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function viewed(Teamer $teamer): Response
{
$teamer->setViewed(true);
$this->entityManager->flush();
return new HxRedirectResponse($this->generateUrl('app_administrative_teamer_index'));
}
}