<?phpnamespace DestiSuiteBundle\Model\DataObject;use Pimcore\Model\DataObject\ContactLocation as ContactLocationBase;use Pimcore\Model\DataObject;use Pimcore\Model\DataObject\Location;class ContactLocation extends ContactLocationBase{ public function getMainName() { if (!empty($this->getName())) { return $this->getName(); } $name = array(); if (!empty($this->getFirstname())) { $name[] = $this->getFirstname(); } if (!empty($this->getLastname())) { $name[] = $this->getLastname(); } return implode(' ', $name); } public function getSecondaryName() { if (!empty($this->getName())) { $name = array(); if (!empty($this->getFirstname())) { $name[] = $this->getFirstname(); } if (!empty($this->getLastname())) { $name[] = $this->getLastname(); } return implode(' ', $name); } return null; } public function getCityName() { if (!empty($this->getCityOverwrite())) { return $this->getCityOverwrite(); } elseif (!empty($this->getCity()) && !empty($this->getCity()->getName())) { return $this->getCity()->getName(); } return ''; } public function getFullAddress($withoutAddress = false) { $fullAddress = array(); if (empty($withoutAddress)) { if (!empty($this->getAddress())) { $fullAddress[] = $this->getAddress(); } if (!empty($this->getAddressNum())) { $fullAddress[] = $this->getAddressNum(); } if (!empty($fullAddress) && (!empty($this->getCity()) || !empty($this->getZipCode()))) { $fullAddress[] = ' - '; } } if (!empty($this->getZipCode())) { $fullAddress[] = $this->getZipCode(); } $cityName = $this->getCityName(); if (!empty($cityName)) { $fullAddress[] = $cityName; } return implode(' ', $fullAddress); } public function getAddressAndNumber() { $str = []; if (!empty($this->getAddress())) { $str[] = $this->getAddress(); } if (!empty($this->getAddressNum())) { $str[] = $this->getAddressNum(); } return implode(' ', $str); } /** * Return the linked city, or the linked city parent if present */ public function getFirstLevelCity() { $city = $this->getCity(); if (empty($city)) { return null; } $parent = $city->getParent(); if (!empty($parent) && $parent instanceof Location) { return $parent; } return $city; }}