modules/acm/src/ACMAddressFormatter.php
public static function postRender($content, array $element) {
    /** @var \CommerceGuys\Addressing\AddressFormat\AddressFormat $address_format */
    $address_format = $element['address_format']['#value'];
    $locale = $element['locale']['#value'];
    // Add the country to the bottom or the top of the format string,
    // depending on whether the format is minor-to-major or major-to-minor.
    if (Locale::match($address_format->getLocale(), $locale)) {
      $format_string = '%country' . "\n" . $address_format->getLocalFormat();
    }
    else {
      $format_string = $address_format->getFormat() . "\n" . '%country';
    }

    // Add the title (prefix) into the format string before the first name.
    // Note: This feels like the wrong place to add address formatting.
    // (notwithstanding %country above).
    // You may inspect the constructor of
    // vendor/commerceguys/addressing/src/AddressFormat/AddressFormat.php
    // And figure out how to extend the class that sets $definition['format']
    // and/or $definition['local_format'].
    // But for now for speed and convenience we inject the %title here.
    // (With some consideration for different locale naming possibilities)
    if (strpos($format_string, '%givenName %familyName') !== FALSE) {
      $format_string = str_replace('%givenName %familyName',
        '%title %givenName %familyName', $format_string);
    }
    elseif (strpos($format_string, '%familyName %givenName') !== FALSE) {
      $format_string = str_replace('%familyName %givenName',
        '%title %familyName %givenName', $format_string);
    }
    elseif (strpos($format_string, '%familyName') !== FALSE) {
      $format_string = str_replace('%familyName',
        '%title %familyName', $format_string);
    }
    elseif (strpos($format_string, '%givenName') !== FALSE) {
      $format_string = str_replace('%givenName',
        '%title %givenName', $format_string);
    }

    $replacements = [];
    foreach (Element::getVisibleChildren($element) as $key) {
      $child = $element[$key];
      if (isset($child['#placeholder'])) {
        $replacements[$child['#placeholder']] = $child['#value'] ? $child['#markup'] : '';
      }
    }
    $content = self::replacePlaceholders($format_string, $replacements);
    $content = nl2br($content, FALSE);

    return $content;
  }
public static function postRender($content, array $element) {
    /** @var \CommerceGuys\Addressing\AddressFormat\AddressFormat $address_format */
    $address_format = $element['address_format']['#value'];
    $locale = $element['locale']['#value'];
    // Add the country to the bottom or the top of the format string,
    // depending on whether the format is minor-to-major or major-to-minor.
    if (Locale::match($address_format->getLocale(), $locale)) {
      $format_string = '%country' . "\n" . $address_format->getLocalFormat();
    }
    else {
      $format_string = $address_format->getFormat() . "\n" . '%country';
    }

    // Add the title (prefix) into the format string before the first name.
    // Note: This feels like the wrong place to add address formatting.
    // (notwithstanding %country above).
    // You may inspect the constructor of
    // vendor/commerceguys/addressing/src/AddressFormat/AddressFormat.php
    // And figure out how to extend the class that sets $definition['format']
    // and/or $definition['local_format'].
    // But for now for speed and convenience we inject the %title here.
    // (With some consideration for different locale naming possibilities)
    if (strpos($format_string, '%givenName %familyName') !== FALSE) {
      $format_string = str_replace('%givenName %familyName',
        '%title %givenName %familyName', $format_string);
    }
    elseif (strpos($format_string, '%familyName %givenName') !== FALSE) {
      $format_string = str_replace('%familyName %givenName',
        '%title %familyName %givenName', $format_string);
    }
    elseif (strpos($format_string, '%familyName') !== FALSE) {
      $format_string = str_replace('%familyName',
        '%title %familyName', $format_string);
    }
    elseif (strpos($format_string, '%givenName') !== FALSE) {
      $format_string = str_replace('%givenName',
        '%title %givenName', $format_string);
    }

    $replacements = [];
    foreach (Element::getVisibleChildren($element) as $key) {
      $child = $element[$key];
      if (isset($child['#placeholder'])) {
        $replacements[$child['#placeholder']] = $child['#value'] ? $child['#markup'] : '';
      }
    }
    $content = self::replacePlaceholders($format_string, $replacements);
    $content = nl2br($content, FALSE);

    return $content;
  }
public static function postRender ( $ content , array $ element ) { /** @var \CommerceGuys\Addressing\AddressFormat\AddressFormat $address_format */ $ address_format = $ element [ 'address_format' ] [ '#value' ] ; $ locale = $ element [ 'locale' ] [ '#value' ] ; // Add the country to the bottom or the top of the format string, // depending on whether the format is minor-to-major or major-to-minor. if ( Locale :: match ( $ address_format -> getLocale ( ) , $ locale ) ) { $ format_string = '%country' . "\n" . $ address_format -> getLocalFormat ( ) ; } else { $ format_string = $ address_format -> getFormat ( ) . "\n" . '%country' ; } // Add the title (prefix) into the format string before the first name. // Note: This feels like the wrong place to add address formatting. // (notwithstanding %country above). // You may inspect the constructor of // vendor/commerceguys/addressing/src/AddressFormat/AddressFormat.php // And figure out how to extend the class that sets $definition['format'] // and/or $definition['local_format']. // But for now for speed and convenience we inject the %title here. // (With some consideration for different locale naming possibilities) if ( strpos ( $ format_string , '%givenName %familyName' ) !== FALSE ) { $ format_string = str_replace ( '%givenName %familyName' , '%title %givenName %familyName' , $ format_string ) ; } elseif ( strpos ( $ format_string , '%familyName %givenName' ) !== FALSE ) { $ format_string = str_replace ( '%familyName %givenName' , '%title %familyName %givenName' , $ format_string ) ; } elseif ( strpos ( $ format_string , '%familyName' ) !== FALSE ) { $ format_string = str_replace ( '%familyName' , '%title %familyName' , $ format_string ) ; } elseif ( strpos ( $ format_string , '%givenName' ) !== FALSE ) { $ format_string = str_replace ( '%givenName' , '%title %givenName' , $ format_string ) ; } $ replacements = [ ] ; foreach ( Element :: getVisibleChildren ( $ element ) as $ key ) { $ child = $ element [ $ key ] ; if ( isset ( $ child [ '#placeholder' ] ) ) { $ replacements [ $ child [ '#placeholder' ] ] = $ child [ '#value' ] ? $ child [ '#markup' ] : '' ; } } $ content = self :: replacePlaceholders ( $ format_string , $ replacements ) ; $ content = nl2br ( $ content , FALSE ) ; return $ content ; }
Inserts the rendered elements into the format string.

Only elements whose placeholders match words in the format string are
added. So if you want to display extra elements, set the
element's #placeholder to '%thing'
and ensure somehow that '%thing' is in format_string.

@param string $content
The rendered element.
@param array $element
An associative array containing the properties and children of the
element.

@return string
The new rendered element.
Inserts the rendered elements into the format string .