You are here

public static function LoqatePcaAddressItem::propertyDefinitions in Loqate 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/LoqatePcaAddressItem.php \Drupal\loqate\Plugin\Field\FieldType\LoqatePcaAddressItem::propertyDefinitions()

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/LoqatePcaAddressItem.php, line 29

Class

LoqatePcaAddressItem
PCA address field item.

Namespace

Drupal\loqate\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties = [];
  $properties[PcaAddressElement::LINE1] = DataDefinition::create('string')
    ->setLabel(new TranslatableMarkup('Address Line 1'));
  $properties[PcaAddressElement::LINE2] = DataDefinition::create('string')
    ->setLabel(new TranslatableMarkup('Address Line 2'));
  $properties[PcaAddressElement::LOCALITY] = DataDefinition::create('string')
    ->setLabel(new TranslatableMarkup('City/Town'));
  $properties[PcaAddressElement::ADMINISTRATIVE_AREA] = DataDefinition::create('string')
    ->setLabel(new TranslatableMarkup('State/Province'));
  $properties[PcaAddressElement::POSTAL_CODE] = DataDefinition::create('string')
    ->setLabel(new TranslatableMarkup('ZIP/Postal Code'));
  $properties[PcaAddressElement::COUNTRY_CODE] = DataDefinition::create('string')
    ->setLabel(new TranslatableMarkup('Country'));
  return $properties;
}