|
- <?php
-
- namespace Lc\CaracoleBundle\Solver\Address;
-
- use Lc\CaracoleBundle\Model\Address\AddressInterface;
- use Lc\CaracoleBundle\Model\Address\AddressModel;
-
- class AddressSolver
- {
- // getAddressSummary
- public function getSummaryShort(AddressInterface $address): string
- {
- return $address->getAddress() . ' - ' . $address->getZip() . ' ' . $address->getCity();
- }
-
- public function getSummary(AddressInterface $address = null, $withTitle = true): string
- {
- if(is_null($address)) {
- return 'Adresse non définie';
- }
-
- $html = '';
-
- if ($address->getTitle() && $withTitle) {
- $html .= $address->getTitle() . '<br />';
- }
-
- if ($address->getLastname() || $address->getFirstname()) {
- $html .= $address->getLastname() . ' ' . $address->getFirstname() . '<br />';
- }
-
- if ($address->getAddress()) {
- $html .= $address->getAddress() . '<br />';
- }
-
- if ($address->getZip() || $address->getCity()) {
- $html .= $address->getZip() . ' ' . $address->getCity() . '<br />';
- }
-
- if ($address->getPhone()) {
- foreach ($address->getPhone() as $phone) {
- $html .= 'Tél. ' . $phone . '<br />';
- }
- }
-
- return $html;
- }
-
- public function getLongitudeInherit(AddressInterface $address): ?string
- {
- if ($address->getLongitudeOverride()) {
- return $address->getLongitudeOverride();
- } else {
- return $address->getLongitude();
- }
- }
-
- public function getLatitudeInherit(AddressInterface $address): ?string
- {
- if ($address->getLatitudeOverride()) {
- return $address->getLatitudeOverride();
- } else {
- return $address->getLatitude();
- }
- }
- public static function getTypeChoices():array{
- return[
- AddressModel::TYPE_INDIVIDUAL,
- AddressModel::TYPE_LEGAL_PERSON,
- ];
- }
-
- }
|