src/Controller/DistrictListController.php line 19

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by simpson <simpsonwork@gmail.com>
  4.  * Date: 2019-03-21
  5.  * Time: 15:39
  6.  */
  7. namespace App\Controller;
  8. use App\Entity\Location\City;
  9. use App\Service\LocationsProfileCounters;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  12. use Symfony\Component\HttpFoundation\Response;
  13. class DistrictListController extends AbstractController
  14. {
  15.     #[ParamConverter("city"converter"city_converter")]
  16.     public function page(City $cityLocationsProfileCounters $locationsProfileCounters): Response
  17.     {
  18.         if (count($city->getDistricts()) < 1) {
  19.             return $this->redirectToRoute('profile_list.list_by_city', ['city' => $city->getUriIdentity()]);
  20.         }
  21.         $countByDistricts $locationsProfileCounters->getCountByDistricts();
  22.         $countByCounties $locationsProfileCounters->getCountByCounties();
  23.         return $this->render('DistrictList/list.html.twig', [
  24.             'city' => $city,
  25.             'count_by_districts' => $countByDistricts,
  26.             'count_by_counties' => $countByCounties,
  27.         ]);
  28.     }
  29. }