コード例 #1
0
 /**
  * Gets the field labels suitable for the given address format.
  *
  * Intended to be shown to the end user, they sometimes use a more familiar
  * term than the field name (Company instead of Organization, Contact name
  * instead of Recipient, etc).
  *
  * @param \Drupal\address\Entity\AddressFormatInterface $address_format
  *   The address format.
  *
  * @return string[]
  *   An array of labels, keyed by field.
  */
 public static function getFieldLabels(AddressFormatInterface $address_format)
 {
     $administrative_area_type = $address_format->getAdministrativeAreaType();
     $locality_type = $address_format->getLocalityType();
     $dependent_locality_type = $address_format->getDependentLocalityType();
     $postal_code_type = $address_format->getPostalCodeType();
     return [AddressField::ADMINISTRATIVE_AREA => self::getAdministrativeAreaLabel($administrative_area_type), AddressField::LOCALITY => self::getLocalityLabel($locality_type), AddressField::DEPENDENT_LOCALITY => self::getDependentLocalityLabel($dependent_locality_type), AddressField::POSTAL_CODE => self::getPostalCodeLabel($postal_code_type), AddressField::SORTING_CODE => t('Cedex'), AddressField::ADDRESS_LINE1 => t('Street address'), AddressField::ADDRESS_LINE2 => t('Street address line 2'), AddressField::ORGANIZATION => t('Company'), AddressField::RECIPIENT => t('Contact name')];
 }