/**
  * {@inheritdoc}
  */
 public function match(AddressInterface $address)
 {
     if ($address->getCountryCode() != $this->configuration['country_code']) {
         return FALSE;
     }
     $administrative_area = $this->configuration['administrative_area'];
     $locality = $this->configuration['locality'];
     $dependent_locality = $this->configuration['dependent_locality'];
     if ($administrative_area && $administrative_area != $address->getAdministrativeArea()) {
         return FALSE;
     }
     if ($locality && $locality != $address->getLocality()) {
         return FALSE;
     }
     if ($dependent_locality && $dependent_locality != $address->getDependentLocality()) {
         return FALSE;
     }
     $included_postal_codes = $this->configuration['included_postal_codes'];
     $excluded_postal_codes = $this->configuration['excluded_postal_codes'];
     if (!PostalCodeHelper::match($address->getPostalCode(), $included_postal_codes, $excluded_postal_codes)) {
         return FALSE;
     }
     return TRUE;
 }
 /**
  * Gets the address values used to build the view.
  *
  * @param AddressInterface       $address       The address.
  * @param AddressFormatInterface $addressFormat The address format.
  *
  * @return array The values, keyed by address field.
  */
 protected function getValues(AddressInterface $address, AddressFormatInterface $addressFormat)
 {
     $values = [];
     foreach (AddressField::getAll() as $field) {
         $getter = 'get' . ucfirst($field);
         $values[$field] = $address->{$getter}();
     }
     // Replace the subdivision values with the names of any predefined ones.
     foreach ($addressFormat->getUsedSubdivisionFields() as $field) {
         if (empty($values[$field])) {
             // This level is empty, so there can be no sublevels.
             break;
         }
         $subdivision = $this->subdivisionRepository->get($values[$field], $address->getLocale());
         if (!$subdivision) {
             // This level has no predefined subdivisions, stop.
             break;
         }
         $values[$field] = $subdivision->getCode();
         if (!$subdivision->hasChildren()) {
             // The current subdivision has no children, stop.
             break;
         }
     }
     return $values;
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function match(AddressInterface $address)
 {
     $eu_countries = ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK'];
     return in_array($address->getCountryCode(), $eu_countries);
 }
 /**
  * {@inheritdoc}
  */
 public function match(AddressInterface $address)
 {
     if ($address->getCountryCode() != $this->countryCode) {
         return false;
     }
     if ($this->administrativeArea && $this->administrativeArea != $address->getAdministrativeArea()) {
         return false;
     }
     if ($this->locality && $this->locality != $address->getLocality()) {
         return false;
     }
     if ($this->dependentLocality && $this->dependentLocality != $address->getDependentLocality()) {
         return false;
     }
     if (!PostalCodeHelper::match($address->getPostalCode(), $this->includedPostalCodes, $this->excludedPostalCodes)) {
         return false;
     }
     return true;
 }