<?php
/**
* Created by simpson <simpsonwork@gmail.com>
* Date: 2019-03-21
* Time: 15:39
*/
namespace App\Controller;
use App\Entity\Location\City;
use App\Service\LocationsProfileCounters;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Response;
class DistrictListController extends AbstractController
{
#[ParamConverter("city", converter: "city_converter")]
public function page(City $city, LocationsProfileCounters $locationsProfileCounters): Response
{
if (count($city->getDistricts()) < 1) {
return $this->redirectToRoute('profile_list.list_by_city', ['city' => $city->getUriIdentity()]);
}
$countByDistricts = $locationsProfileCounters->getCountByDistricts();
$countByCounties = $locationsProfileCounters->getCountByCounties();
return $this->render('DistrictList/list.html.twig', [
'city' => $city,
'count_by_districts' => $countByDistricts,
'count_by_counties' => $countByCounties,
]);
}
}