Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

AddressSolver.php 1.9KB

il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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, $withTitle = true): string
  13. {
  14. $html = '';
  15. if ($address->getTitle() && $withTitle) {
  16. $html .= $address->getTitle() . '<br />';
  17. }
  18. if ($address->getLastname() || $address->getFirstname()) {
  19. $html .= $address->getLastname() . ' ' . $address->getFirstname() . '<br />';
  20. }
  21. if ($address->getAddress()) {
  22. $html .= $address->getAddress() . '<br />';
  23. }
  24. if ($address->getZip() || $address->getCity()) {
  25. $html .= $address->getZip() . ' ' . $address->getCity() . '<br />';
  26. }
  27. if ($address->getPhone()) {
  28. foreach ($address->getPhone() as $phone) {
  29. $html .= 'Tél. ' . $phone . '<br />';
  30. }
  31. }
  32. return $html;
  33. }
  34. public function getLongitudeInherit(AddressInterface $address): ?string
  35. {
  36. if ($address->getLongitudeOverride()) {
  37. return $address->getLongitudeOverride();
  38. } else {
  39. return $address->getLongitude();
  40. }
  41. }
  42. public function getLatitudeInherit(AddressInterface $address): ?string
  43. {
  44. if ($address->getLatitudeOverride()) {
  45. return $address->getLatitudeOverride();
  46. } else {
  47. return $address->getLatitude();
  48. }
  49. }
  50. public static function getTypeChoices():array{
  51. return[
  52. AddressModel::TYPE_INDIVIDUAL,
  53. AddressModel::TYPE_LEGAL_PERSON,
  54. ];
  55. }
  56. }