You are here

public static function AddressItem::propertyDefinitions in Address 8

Defines field item properties.

Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.

Overrides FieldItemInterface::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

File

src/Plugin/Field/FieldType/AddressItem.php, line 106

Class

AddressItem
Plugin implementation of the 'address' field type.

Namespace

Drupal\address\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties = [];
  $properties['langcode'] = DataDefinition::create('string')
    ->setLabel(t('The language code'));
  $properties['country_code'] = DataDefinition::create('string')
    ->setLabel(t('The two-letter country code'));
  $properties['administrative_area'] = DataDefinition::create('string')
    ->setLabel(t('The top-level administrative subdivision of the country'));
  $properties['locality'] = DataDefinition::create('string')
    ->setLabel(t('The locality (i.e. city)'));
  $properties['dependent_locality'] = DataDefinition::create('string')
    ->setLabel(t('The dependent locality (i.e. neighbourhood)'));
  $properties['postal_code'] = DataDefinition::create('string')
    ->setLabel(t('The postal code'));
  $properties['sorting_code'] = DataDefinition::create('string')
    ->setLabel(t('The sorting code'));
  $properties['address_line1'] = DataDefinition::create('string')
    ->setLabel(t('The first line of the address block'));
  $properties['address_line2'] = DataDefinition::create('string')
    ->setLabel(t('The second line of the address block'));
  $properties['organization'] = DataDefinition::create('string')
    ->setLabel(t('The organization'));
  $properties['given_name'] = DataDefinition::create('string')
    ->setLabel(t('The given name'));
  $properties['additional_name'] = DataDefinition::create('string')
    ->setLabel(t('The additional name'));
  $properties['family_name'] = DataDefinition::create('string')
    ->setLabel(t('The family name'));
  return $properties;
}