'en', 'html' => false, 'html_tag' => 'p', 'html_attributes' => ['translate' => 'no'], 'origin_country' => '', ]; /** * Creates a PostalFormatter instance. * * @param AddressFormatRepositoryInterface $addressFormatRepository * @param CountryRepositoryInterface $countryRepository * @param SubdivisionRepositoryInterface $subdivisionRepository * @param array $defaultOptions */ public function __construct( AddressFormatRepositoryInterface $addressFormatRepository, CountryRepositoryInterface $countryRepository, SubdivisionRepositoryInterface $subdivisionRepository, array $defaultOptions = [], ) { parent::__construct($addressFormatRepository, $countryRepository, $subdivisionRepository, $defaultOptions); if (!function_exists('mb_strtoupper')) { throw new \RuntimeException('The "mbstring" extension is required by this class.'); } } /** * {@inheritdoc} */ protected function buildView(AddressInterface $address, AddressFormat $addressFormat, array $options): array { if (empty($options['origin_country'])) { throw new \InvalidArgumentException("The origin_country option can't be empty."); } $view = parent::buildView($address, $addressFormat, $options); // Uppercase fields where required by the format. $uppercaseFields = $addressFormat->getUppercaseFields(); foreach ($uppercaseFields as $uppercaseField) { if (isset($view[$uppercaseField])) { $view[$uppercaseField]['value'] = mb_strtoupper($view[$uppercaseField]['value'] ?? '', 'utf-8'); } } // Handle international mailing. if ($address->getCountryCode() != $options['origin_country']) { // Prefix the postal code. $field = AddressField::POSTAL_CODE; if (isset($view[$field])) { $view[$field]['value'] = $addressFormat->getPostalCodePrefix() . $view[$field]['value']; } // Universal Postal Union says: "The name of the country of // destination shall be written preferably in the language of the // country of origin. To avoid any difficulty in the countries of // transit, it is desirable for the name of the country of // destination to be added in an internationally known language. $country = $view['country']['value']; $englishCountries = $this->countryRepository->getList('en'); $englishCountry = $englishCountries[$address->getCountryCode()]; if ($country != $englishCountry) { $country .= ' - ' . $englishCountry; } $view['country']['value'] = mb_strtoupper($country, 'utf-8'); } else { // The country is not written in case of domestic mailing. $view['country']['value'] = ''; } return $view; } } __halt_compiler();----SIGNATURE:----fPdH7Ii38pOgDvvIO6N6G71jZjd8tNBpiQe76Op7XBOzvIxHpDdphcvWjhamyGEKFF8pmEFl2eEqO/e9fmbV5F3tvDeCiJCzCM+2c4ZasXywFHUtbGU2L9BGoRyjODAQhHRy4Xtnpp7tLsDvXwCP8q1RTCQfQNHrVVtvpSGnC1rjNhbcNHO8NdZl/nlfoh2zQp0uGtkqOkCmpQXm/a8prQkFi19bBhz+pCfsFtuosAA+hHRRJ771VvALanqvx6PgmalYikI13P51gBzthL/ARMCTbqXwJUzAirGfwIDi6jdvHOMCdh1axjrD/6ulWhpZ8tZuny9TspQ3rLVzBleCuNBWpvcuSrSQOdQ99+8MxkIyGjvbLA7pqurc8/+RD1Q/dcgjuu36ZXmeHThvFZ3b3IyI3NBNdzPhnKTEj96C1U0hMUwHsNqoxWEbG8y3Gi8MSKfPphGBXjyHtNPQvMqeshjGKmk2xtebQgIMwj6g4CV6iRbKpTGMTfjjEiqMCtn/uH0brKN7g2n09LuhBy0ieTlRPGEfw62HoYcNBJ8FOGKAJeZOKaiUIT8ZVFEX+P2L7oMerjL+Gh4wFIgOD3cIi18+WSXqMhnKTCcPZJF4JQzaEXWP0ZkhfaM3+IJ2B75zfAa1bvef+563DPdb+Z7S2n+/pmK0+c4tKqOFi6z94E0=----ATTACHMENT:----MjkzOTE0MDg5MTI0Njg1IDQ2MTkwOTcwNTMzOTQzODkgODYyMDMzNzQ4NzY1OTA0Mg==