<?php
declare(strict_types=1);
namespace App\Controller;
use App\Entity\LocationInterface;
use App\Repository\JobRepositoryInterface;
use App\Repository\LocationRepositoryInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class OfficeController extends AbstractController
{
private LocationRepositoryInterface $locationRepository;
private JobRepositoryInterface $jobRepository;
public function __construct(LocationRepositoryInterface $locationRepository, JobRepositoryInterface $jobRepository)
{
$this->locationRepository = $locationRepository;
$this->jobRepository = $jobRepository;
}
/**
* @Route("/our-locations", name="office_index")
*/
public function index(): Response
{
$locations = $this
->locationRepository
->findAll();
$jobs = $this
->jobRepository
->createActiveQueryBuilder()
->setMaxResults(3)
->getQuery()
->getResult();
return $this->render('page/office/index/index.html.twig', [
'locations' => $locations,
'jobs' => $jobs
]);
}
/**
* @Route("/location/{location}", name="office_show")
*/
public function show(LocationInterface $location): Response
{
$jobs = $this
->jobRepository
->findActiveByLocation($location);
return $this->render('page/office/show/show.html.twig', [
'location' => $location,
'jobs' => $jobs
]);
}
}