<?php
namespace App\Controller;
use App\Api\BrcBackend\DTO\CityProfilesList;
use App\Api\BrcBackend\DTO\Profile;
use App\Api\BrcBackend\DTO\ProfilesList;
use App\Form\SearchType;
use App\Service\Paginator\PaginatorBuilder;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
final class CompanyController extends AbstractController
{
/**
* @Route("/company/list/{page}", name="company_list", defaults={"page"=null}, methods={"GET"})
*
* @throws \Throwable
*/
public function list(ProfilesList $profiles, PaginatorBuilder $paginator): Response
{
return $this->render('company/list.html.twig', [
'profiles' => $profiles->getProfiles(),
'pagination' => $paginator->build($profiles->getPage(), $profiles->getTotalPages()),
'currentPage' => $profiles->getPage(),
'form' => $this->createForm(SearchType::class)->createView(),
]);
}
/**
* @Route("/city/{id}-{slug}/companies/{page}", name="city_companies_list", defaults={"page"=null}, methods={"GET"})
*/
public function getCityCompaniesList(CityProfilesList $list, PaginatorBuilder $paginator): Response
{
return $this->render('company/city_companies_list.html.twig', [
'profiles' => $list->getProfiles(),
'city' => $list->getCity(),
'pagination' => $paginator->build($list->getPage(), $list->getTotalPages()),
'currentPage' => $list->getPage(),
'form' => $this->createForm(SearchType::class)->createView(),
]);
}
/**
* @Route("/company/{id}-{slug}", name="company_show", methods={"GET"})
*/
public function show(Profile $profile): Response
{
return $this->render('company/show.html.twig', ['profile' => $profile]);
}
}