51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Teamer\Bookmark;
|
|
|
|
use App\Entity\User;
|
|
use App\Repository\AssignmentRepository;
|
|
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\Attribute\Route;
|
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
|
class IndexController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly AssignmentRepository $assignmentRepository,
|
|
private readonly PaginatorInterface $paginator,
|
|
) {
|
|
}
|
|
|
|
#[Route('/teamer/bookmark', name: 'app_teamer_bookmark_index')]
|
|
#[IsGranted('ROLE_TEAMER')]
|
|
public function index(Request $request): Response
|
|
{
|
|
/** @var User $user */
|
|
$user = $this->getUser();
|
|
$teamer = $user->getTeamer();
|
|
|
|
$query = $this
|
|
->assignmentRepository
|
|
->getBookmarkQueryForTeamer($teamer)
|
|
;
|
|
|
|
$pagination = $this->paginator->paginate(
|
|
$query,
|
|
$request->query->getInt('page', 1),
|
|
9,
|
|
[
|
|
'defaultSortFieldName' => 'assignment.dateFrom',
|
|
'defaultSortDirection' => 'asc',
|
|
]
|
|
);
|
|
|
|
return $this->render('teamer/bookmark/index.html.twig', [
|
|
'teamer' => $teamer,
|
|
'pagination' => $pagination,
|
|
]);
|
|
}
|
|
}
|