src/Controller/DefaultController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\BusinessService;
  4. use App\Service\PhoneFormater;
  5. use Pimcore\Controller\FrontendController;
  6. use Pimcore\Model\DataObject\Language;
  7. use Pimcore\Model\DataObject\Organisation;
  8. use Pimcore\Model\DataObject\Services;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Pimcore\Model\WebsiteSetting;
  13. class DefaultController extends FrontendController
  14. {
  15.     /**
  16.      * @Template
  17.      * @param Request $request
  18.      * @return array
  19.      */
  20.     public function defaultAction(Request $request)
  21.     {
  22.         return [];
  23.     }
  24.     /**
  25.      * @Template
  26.      * @param Request $request
  27.      * @return array
  28.      */
  29.     public function homeAction(Request $request)
  30.     {
  31.         $services = new Services\Listing();
  32.         $services->setOrderKey('position');
  33.         $services->setOrder('ASC');
  34.         $services->load();
  35.         $langs = new Language\Listing();
  36.         $langs->load();
  37.         $websetting WebsiteSetting::getByName("avalaibilitiesCount");
  38.         return ["services"=>$services"langs" => $langs"totalBusinesses" => BusinessService::countPartners(), "availablePlaces" => $websetting->getData() ];
  39.     }
  40.     /**
  41.      * @Template
  42.      * @param Request $request
  43.      * @route("/{_locale}/search", name="search",methods={"GET"})
  44.      * @return array
  45.      */
  46.     public function searchAction(Request $request)
  47.     {
  48.         $services = new Services\Listing();
  49.         $services->setOrderKey('position');
  50.         $services->setOrder('ASC');
  51.         $services->load();
  52.         $langs = new Language\Listing();
  53.         $langs->load();
  54.         $organisations = new Organisation\Listing();
  55.         $organisations->setOrderKey('name');
  56.         $organisations->setOrder('ASC');
  57.         $organisations->load();
  58.         return ["services"=>$services"langs" => $langs"organisations" => $organisations ];
  59.     }
  60. }