vendor/marketingfactory/destisuite/src/DestiSuiteBundle/Model/DataObject/ContactLocation.php line 9

Open in your IDE?
  1. <?php
  2. namespace DestiSuiteBundle\Model\DataObject;
  3. use Pimcore\Model\DataObject\ContactLocation as ContactLocationBase;
  4. use Pimcore\Model\DataObject;
  5. use Pimcore\Model\DataObject\Location;
  6. class ContactLocation extends ContactLocationBase
  7. {
  8.     public function getMainName()
  9.     {
  10.         if (!empty($this->getName())) {
  11.             return $this->getName();
  12.         }
  13.         
  14.         $name = array();
  15.         if (!empty($this->getFirstname())) {
  16.             $name[] = $this->getFirstname();
  17.         }
  18.         if (!empty($this->getLastname())) {
  19.             $name[] = $this->getLastname();
  20.         }
  21.         return implode(' '$name);
  22.     }
  23.     
  24.     public function getSecondaryName()
  25.     {
  26.         if (!empty($this->getName())) {
  27.             $name = array();
  28.             if (!empty($this->getFirstname())) {
  29.                 $name[] = $this->getFirstname();
  30.             }
  31.             if (!empty($this->getLastname())) {
  32.                 $name[] = $this->getLastname();
  33.             }
  34.             return implode(' '$name);
  35.         }
  36.         
  37.         return null;
  38.     }
  39.     
  40.     public function getCityName()
  41.     {
  42.         if (!empty($this->getCityOverwrite())) {
  43.             return $this->getCityOverwrite();
  44.         } elseif (!empty($this->getCity()) && !empty($this->getCity()->getName())) {
  45.             return $this->getCity()->getName();
  46.         }
  47.         return '';
  48.     }
  49.     
  50.     public function getFullAddress($withoutAddress false)
  51.     {
  52.         $fullAddress = array();
  53.         
  54.         if (empty($withoutAddress)) {
  55.             if (!empty($this->getAddress())) {
  56.                 $fullAddress[] = $this->getAddress();
  57.             }
  58.             if (!empty($this->getAddressNum())) {
  59.                 $fullAddress[] = $this->getAddressNum();
  60.             }
  61.             if (!empty($fullAddress) && (!empty($this->getCity()) || !empty($this->getZipCode()))) {
  62.                 $fullAddress[] = ' - ';
  63.             }
  64.         }
  65.         
  66.         if (!empty($this->getZipCode())) {
  67.             $fullAddress[] = $this->getZipCode();
  68.         }
  69.         
  70.         $cityName $this->getCityName();
  71.         if (!empty($cityName)) {
  72.             $fullAddress[] = $cityName;
  73.         }
  74.         
  75.         return implode(' '$fullAddress);
  76.     }
  77.     
  78.     public function getAddressAndNumber()
  79.     {
  80.         $str = [];
  81.         if (!empty($this->getAddress())) {
  82.             $str[] = $this->getAddress();
  83.         }
  84.         if (!empty($this->getAddressNum())) {
  85.             $str[] = $this->getAddressNum();
  86.         }
  87.         
  88.         return implode(' '$str);
  89.     }
  90.     
  91.     /**
  92.      * Return the linked city, or the linked city parent if present
  93.      */
  94.     public function getFirstLevelCity()
  95.     {
  96.         $city $this->getCity();
  97.         if (empty($city)) {
  98.             return null;
  99.         }
  100.         $parent $city->getParent();
  101.         if (!empty($parent) && $parent instanceof Location) {
  102.             return $parent;
  103.         }
  104.         return $city;
  105.     }
  106. }