You are here

public static function Address::applyDefaults in Address 8

Ensures all keys are set on the provided value.

Parameters

array $value: The value.

Return value

array The modified value.

1 call to Address::applyDefaults()
Address::valueCallback in src/Element/Address.php
Determines how user input is mapped to an element's #value property.

File

src/Element/Address.php, line 97

Class

Address
Provides an address form element.

Namespace

Drupal\address\Element

Code

public static function applyDefaults(array $value) {
  $properties = [
    'given_name',
    'additional_name',
    'family_name',
    'organization',
    'address_line1',
    'address_line2',
    'postal_code',
    'sorting_code',
    'dependent_locality',
    'locality',
    'administrative_area',
    'country_code',
    'langcode',
  ];
  foreach ($properties as $property) {
    if (!isset($value[$property])) {
      $value[$property] = NULL;
    }
  }
  return $value;
}