Commit 01cdc9b3 authored by Jonathan Sacksick's avatar Jonathan Sacksick Committed by Jonathan Sacksick
Browse files

Issue #3302484 by bojanz, jsacksick, mglaman, COBadger: commerceguys/addressing 1.4 compatibility.

parent 82604ddb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
    "require": {
        "php": "^7.3 || ^8.0",
        "drupal/core": "^9.2 || ^10",
        "commerceguys/addressing": "^1.2.0"
        "commerceguys/addressing": "^1.4.0"
    },
    "require-dev": {
        "drupal/token": "^1.0"
+2 −2
Original line number Diff line number Diff line
@@ -5,8 +5,8 @@
            "url": "https://github.com/doctrine/collections/archive/1.6.8.zip"
        },
        "commerceguys/addressing": {
            "version": "v1.2.2",
            "url": "https://github.com/commerceguys/addressing/archive/v1.2.2.zip"
            "version": "v1.4.0",
            "url": "https://github.com/commerceguys/addressing/archive/v1.4.0.zip"
        }
    }
}
+24 −24
Original line number Diff line number Diff line
@@ -362,85 +362,85 @@ class AddressItem extends FieldItemBase implements AddressInterface {
  /**
   * {@inheritdoc}
   */
  public function getCountryCode() {
    return $this->country_code;
  public function getCountryCode(): string {
    return $this->country_code ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getAdministrativeArea() {
    return $this->administrative_area;
  public function getAdministrativeArea(): string {
    return $this->administrative_area ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getLocality() {
    return $this->locality;
  public function getLocality(): string {
    return $this->locality ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getDependentLocality() {
    return $this->dependent_locality;
  public function getDependentLocality(): string {
    return $this->dependent_locality ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getPostalCode() {
    return $this->postal_code;
  public function getPostalCode(): string {
    return $this->postal_code ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getSortingCode() {
    return $this->sorting_code;
  public function getSortingCode(): string {
    return $this->sorting_code ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getAddressLine1() {
    return $this->address_line1;
  public function getAddressLine1(): string {
    return $this->address_line1 ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getAddressLine2() {
    return $this->address_line2;
  public function getAddressLine2(): string {
    return $this->address_line2 ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getOrganization() {
    return $this->organization;
  public function getOrganization(): string {
    return $this->organization ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getGivenName() {
    return $this->given_name;
  public function getGivenName(): string {
    return $this->given_name ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getAdditionalName() {
    return $this->additional_name;
  public function getAdditionalName(): string {
    return $this->additional_name ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getFamilyName() {
    return $this->family_name;
  public function getFamilyName(): string {
    return $this->family_name ?? '';
  }

}
+3 −1
Original line number Diff line number Diff line
@@ -2,12 +2,14 @@

namespace Drupal\address\Plugin\Validation\Constraint;

use CommerceGuys\Addressing\AddressFormat\AddressField;
use CommerceGuys\Addressing\AddressFormat\AddressFormat;
use CommerceGuys\Addressing\Validator\Constraints\AddressFormatConstraintValidator as ExternalValidator;
use Drupal\address\FieldHelper;
use Drupal\address\LabelHelper;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Validator\Constraint;

/**
 * Validates the address format constraint.
@@ -27,7 +29,7 @@ class AddressFormatConstraintValidator extends ExternalValidator implements Cont
  /**
   * {@inheritdoc}
   */
  protected function addViolation($field, $message, $invalid_value, AddressFormat $address_format) {
  protected function addViolation(string $field, string $message, $invalid_value, AddressFormat $address_format) {
    $labels = LabelHelper::getFieldLabels($address_format);
    $label = $labels[$field];

+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ class AddressFormatRepository extends ExternalAddressFormatRepository {
  /**
   * {@inheritdoc}
   */
  protected function processDefinition($countryCode, array $definition) {
  protected function processDefinition($countryCode, array $definition): array {
    $definition = parent::processDefinition($countryCode, $definition);
    // Allow other modules to alter the address format.
    $event = new AddressFormatEvent($definition);
Loading