bundles/FoxHabbit/BasisBundle/Document/Areabrick/Parts/BasisbundlePartGooglemap.php line 36

Open in your IDE?
  1. <?php
  2. namespace FoxHabbit\BasisBundle\Document\Areabrick\Parts;
  3. use AppBundle\Service\PartnersService;
  4. use FoxHabbit\BasisBundle\Document\AreabrickTwig;
  5. use Pimcore\Config;
  6. use Pimcore\Model\DataObject\Partner;
  7. use Pimcore\Model\Document\Editable\Area\Info;
  8. class BasisbundlePartGooglemap extends AreabrickTwig
  9. {
  10.     protected $partnersService;
  11.     protected $config;
  12.     public function __construct(PartnersService $partnersServiceConfig $config)
  13.     {
  14.         $this->partnersService $partnersService;
  15.         $this->config $config;
  16.     }
  17.     protected function getTemplateSubfolder()
  18.     {
  19.         return 'parts/';
  20.     }
  21.     /**
  22.      * @param Info $info
  23.      *
  24.      * @throws \Exception
  25.      */
  26.     public function action(Info $info)
  27.     {
  28.         parent::action($info);
  29.         //$config = Config::getSystemConfig();
  30.         $googleMapsKey null;
  31.         $googleMapsKeySetting \Pimcore\Model\WebsiteSetting::getByName('GoogleMapsKey');
  32.         if($googleMapsKeySetting){
  33.             $googleMapsKey $googleMapsKeySetting->getData();
  34.         }
  35.         $info->setParam("apikey"$googleMapsKey);
  36.         // ===========================================
  37.         // Dealer search stuff
  38.         // ===========================================
  39.         $preselectedPartnerType $this->getDocumentEditable($info->getDocument(), 'select''preselected_partners')->getData();
  40.         $preselectedCountry $this->getDocumentEditable($info->getDocument(), 'select''preselected_country')->getData();
  41.         if( $preselectedCountry && strlen$preselectedCountry) !== 2) {
  42.             $preselectedCountry null;
  43.         }
  44.         $partnersList = new Partner\Listing();
  45.         $partnersList->setOrderKey("companyName");
  46.         $partnersList->filterByTypeFieldKEI(0);
  47.         $partnersTypes PartnersService::getPartnerTypes();
  48.         if ($preselectedPartnerType && in_array($preselectedPartnerType$partnersTypes)) {
  49.             if( $preselectedCountry) {
  50.                 $partnersList->setCondition("`typeField".$preselectedPartnerType."` and country = ?", [$preselectedCountry]);
  51.             } else {
  52.                 $partnersList->setCondition("`typeField".$preselectedPartnerType."`");
  53.             }
  54.         } else {
  55.             if( $preselectedCountry) {
  56.                 $partnersList->setCondition("country = ?", [$preselectedCountry]);
  57.             }
  58.             $preselectedPartnerType 'all';
  59.         }
  60.         $countries $this->partnersService->getPartnerCountries($partnersList);
  61.         $partners $this->partnersService->partnersDisplayDataForPartnersList($partnersList,$info->getRequest()->getLocale(), $info->getDocument());
  62.         $info->setParam("countries"$countries);
  63.         $info->setParam("preselectedPartnerType"$preselectedPartnerType);
  64.         $info->setParam("partners"$partners);
  65.         $info->setParam("numberOfPartners"count($partners));
  66.         $info->setParam("validPartnerTypes"$partnersTypes);
  67.     }
  68. }