<?php
namespace App\Controller;
use App\Service\BusinessService;
use App\Service\PhoneFormater;
use Pimcore\Controller\FrontendController;
use Pimcore\Model\DataObject\Language;
use Pimcore\Model\DataObject\Organisation;
use Pimcore\Model\DataObject\Services;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
use Pimcore\Model\WebsiteSetting;
class DefaultController extends FrontendController
{
/**
* @Template
* @param Request $request
* @return array
*/
public function defaultAction(Request $request)
{
return [];
}
/**
* @Template
* @param Request $request
* @return array
*/
public function homeAction(Request $request)
{
$services = new Services\Listing();
$services->setOrderKey('position');
$services->setOrder('ASC');
$services->load();
$langs = new Language\Listing();
$langs->load();
$websetting = WebsiteSetting::getByName("avalaibilitiesCount");
return ["services"=>$services, "langs" => $langs, "totalBusinesses" => BusinessService::countPartners(), "availablePlaces" => $websetting->getData() ];
}
/**
* @Template
* @param Request $request
* @route("/{_locale}/search", name="search",methods={"GET"})
* @return array
*/
public function searchAction(Request $request)
{
$services = new Services\Listing();
$services->setOrderKey('position');
$services->setOrder('ASC');
$services->load();
$langs = new Language\Listing();
$langs->load();
$organisations = new Organisation\Listing();
$organisations->setOrderKey('name');
$organisations->setOrder('ASC');
$organisations->load();
return ["services"=>$services, "langs" => $langs, "organisations" => $organisations ];
}
}