You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 satır
2.0KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Solver\Address;
  3. use Lc\CaracoleBundle\Model\Address\AddressInterface;
  4. use Lc\CaracoleBundle\Model\Address\AddressModel;
  5. class AddressSolver
  6. {
  7. // getAddressSummary
  8. public function getSummaryShort(AddressInterface $address): string
  9. {
  10. return $address->getAddress() . ' - ' . $address->getZip() . ' ' . $address->getCity();
  11. }
  12. public function getSummary(AddressInterface $address = null, $withTitle = true): string
  13. {
  14. if(is_null($address)) {
  15. return 'Adresse non définie';
  16. }
  17. $html = '';
  18. if ($address->getTitle() && $withTitle) {
  19. $html .= $address->getTitle() . '<br />';
  20. }
  21. if ($address->getLastname() || $address->getFirstname()) {
  22. $html .= $address->getLastname() . ' ' . $address->getFirstname() . '<br />';
  23. }
  24. if ($address->getAddress()) {
  25. $html .= $address->getAddress() . '<br />';
  26. }
  27. if ($address->getZip() || $address->getCity()) {
  28. $html .= $address->getZip() . ' ' . $address->getCity() . '<br />';
  29. }
  30. if ($address->getPhone()) {
  31. foreach ($address->getPhone() as $phone) {
  32. $html .= 'Tél. ' . $phone . '<br />';
  33. }
  34. }
  35. return $html;
  36. }
  37. public function getLongitudeInherit(AddressInterface $address): ?string
  38. {
  39. if ($address->getLongitudeOverride()) {
  40. return $address->getLongitudeOverride();
  41. } else {
  42. return $address->getLongitude();
  43. }
  44. }
  45. public function getLatitudeInherit(AddressInterface $address): ?string
  46. {
  47. if ($address->getLatitudeOverride()) {
  48. return $address->getLatitudeOverride();
  49. } else {
  50. return $address->getLatitude();
  51. }
  52. }
  53. public static function getTypeChoices():array{
  54. return[
  55. AddressModel::TYPE_INDIVIDUAL,
  56. AddressModel::TYPE_LEGAL_PERSON,
  57. ];
  58. }
  59. }