47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Teamer\Disposition;
|
|
|
|
use App\Entity\User;
|
|
use App\Service\Season\SeasonAssignmentResolver;
|
|
use App\Service\Teamer\UpcomingPlacementCollector;
|
|
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 UpcomingController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly UpcomingPlacementCollector $upcomingPlacementCollector,
|
|
private readonly SeasonAssignmentResolver $seasonAssignmentResolver,
|
|
private readonly PaginatorInterface $paginator,
|
|
) {
|
|
}
|
|
|
|
#[Route('/teamer/disposition/upcoming', name: 'app_teamer_disposition_upcoming')]
|
|
#[IsGranted('ROLE_TEAMER')]
|
|
public function index(Request $request): Response
|
|
{
|
|
/** @var User $user */
|
|
$user = $this->getUser();
|
|
$teamer = $user->getTeamer();
|
|
|
|
// an array rather than a query: dispositions and season assignments are merged in PHP
|
|
$pagination = $this->paginator->paginate(
|
|
$this->upcomingPlacementCollector->collect($teamer),
|
|
$request->query->getInt('page', 1),
|
|
9
|
|
);
|
|
|
|
return $this->render('teamer/disposition/upcoming.html.twig', [
|
|
'teamer' => $teamer,
|
|
'pagination' => $pagination,
|
|
// the season page shows only this one, so only this one is linked
|
|
'linkedSeasonAssignment' => $this->seasonAssignmentResolver->resolveFor($teamer),
|
|
]);
|
|
}
|
|
}
|