/**
  * Builds a renderable array for a single address item.
  *
  * @param \Drupal\address\AddressInterface $address
  *   The address.
  * @param string $langcode
  *   The language that should be used to render the field.
  *
  * @return array
  *   A renderable array.
  */
 protected function viewElement(AddressInterface $address, $langcode)
 {
     $country_code = $address->getCountryCode();
     $countries = $this->countryRepository->getList();
     $address_format = $this->addressFormatRepository->get($country_code, $address->getLocale());
     $values = $this->getValues($address, $address_format);
     $element = [];
     $element['address_format'] = ['#type' => 'value', '#value' => $address_format];
     $element['country_code'] = ['#type' => 'value', '#value' => $country_code];
     $element['country'] = ['#type' => 'html_tag', '#tag' => 'span', '#attributes' => ['class' => ['country']], '#value' => Html::escape($countries[$country_code]), '#placeholder' => '%country'];
     foreach ($address_format->getUsedFields() as $field) {
         $property = FieldHelper::getPropertyName($field);
         $class = str_replace('_', '-', $property);
         $element[$property] = ['#type' => 'html_tag', '#tag' => 'span', '#attributes' => ['class' => [$class]], '#value' => Html::escape($values[$field]), '#placeholder' => '%' . $field];
     }
     return $element;
 }
 /**
  * Builds a renderable array for a single address item.
  *
  * @param \Drupal\address\AddressInterface $address
  *   The address.
  * @param string $langcode
  *   The language that should be used to render the field.
  *
  * @return array
  *   A renderable array.
  */
 protected function viewElement(AddressInterface $address, $langcode)
 {
     $country_code = $address->getCountryCode();
     $countries = $this->countryRepository->getList();
     $address_format = $this->addressFormatRepository->get($country_code, $address->getLocale());
     $values = $this->getValues($address, $address_format);
     $element = ['#theme' => 'address_plain', '#recipient' => $values['recipient'], '#organization' => $values['organization'], '#address_line1' => $values['addressLine1'], '#address_line2' => $values['addressLine2'], '#postal_code' => $values['postalCode'], '#sorting_code' => $values['sortingCode'], '#administrative_area' => $values['administrativeArea'], '#locality' => $values['locality'], '#dependent_locality' => $values['dependentLocality'], '#country' => ['code' => $country_code, 'name' => $countries[$country_code]], '#cache' => ['contexts' => ['languages:' . LanguageInterface::TYPE_INTERFACE]]];
     return $element;
 }