Loading src/Helper/PostalCodeHelper.php +17 −3 Original line number Diff line number Diff line Loading @@ -20,8 +20,12 @@ class PostalCodeHelper implements PostalCodeHelperInterface { /** * The zipcodes URL from bpost. * * Unfortunately this is currently hosted on an HTTP only server. * * @see: https://www.bpost.be/nl/postcodevalidatie-tool */ const ZIPCODES_URL = "http://www.bpost2.be/zipcodes/files/zipcodes_num_nl_new.xls"; protected const ZIPCODES_URL = "http://www.bpost2.be/zipcodes/files/zipcodes_num_nl_new.xls"; /** * PostalCodeHelper constructor. Loading Loading @@ -49,8 +53,18 @@ class PostalCodeHelper implements PostalCodeHelperInterface { /** * {@inheritdoc} */ public function getMunicipalityByPostalCode(string $postalCode) { // @todo Implement. public function getMunicipalitiesByPostalCode(string $postalCode): array { $term_ids = $this->entityTypeManager ->getStorage('taxonomy_term') ->getQuery() ->condition('field_postal_code_be', $postalCode) ->execute(); if ($term_ids) { return $this->entityTypeManager->getStorage('taxonomy_term')->loadMultiple($term_ids); } return []; } /** Loading src/Helper/PostalCodeHelperInterface.php +9 −2 Original line number Diff line number Diff line Loading @@ -23,11 +23,18 @@ interface PostalCodeHelperInterface { public function downloadPostalCodeFile(): mixed; /** * Loads all municipalities by a given postal code. * * It's not possible to return a single municipality this way because in * Belgium it is possible that multiple cities share the same postal code. * * @param string $postalCode * The postal code as string. * * @return mixed * @return array * An array of postal code terms if there are results. */ public function getMunicipalityByPostalCode(string $postalCode); public function getMunicipalitiesByPostalCode(string $postalCode): array; /** * @param string $municipality Loading Loading
src/Helper/PostalCodeHelper.php +17 −3 Original line number Diff line number Diff line Loading @@ -20,8 +20,12 @@ class PostalCodeHelper implements PostalCodeHelperInterface { /** * The zipcodes URL from bpost. * * Unfortunately this is currently hosted on an HTTP only server. * * @see: https://www.bpost.be/nl/postcodevalidatie-tool */ const ZIPCODES_URL = "http://www.bpost2.be/zipcodes/files/zipcodes_num_nl_new.xls"; protected const ZIPCODES_URL = "http://www.bpost2.be/zipcodes/files/zipcodes_num_nl_new.xls"; /** * PostalCodeHelper constructor. Loading Loading @@ -49,8 +53,18 @@ class PostalCodeHelper implements PostalCodeHelperInterface { /** * {@inheritdoc} */ public function getMunicipalityByPostalCode(string $postalCode) { // @todo Implement. public function getMunicipalitiesByPostalCode(string $postalCode): array { $term_ids = $this->entityTypeManager ->getStorage('taxonomy_term') ->getQuery() ->condition('field_postal_code_be', $postalCode) ->execute(); if ($term_ids) { return $this->entityTypeManager->getStorage('taxonomy_term')->loadMultiple($term_ids); } return []; } /** Loading
src/Helper/PostalCodeHelperInterface.php +9 −2 Original line number Diff line number Diff line Loading @@ -23,11 +23,18 @@ interface PostalCodeHelperInterface { public function downloadPostalCodeFile(): mixed; /** * Loads all municipalities by a given postal code. * * It's not possible to return a single municipality this way because in * Belgium it is possible that multiple cities share the same postal code. * * @param string $postalCode * The postal code as string. * * @return mixed * @return array * An array of postal code terms if there are results. */ public function getMunicipalityByPostalCode(string $postalCode); public function getMunicipalitiesByPostalCode(string $postalCode): array; /** * @param string $municipality Loading