You are here

public function FormattedAddress::format in Geocoder 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/Geocoder/Formatter/FormattedAddress.php \Drupal\geocoder\Plugin\Geocoder\Formatter\FormattedAddress::format()

Dumps the argument into a specific format.

Parameters

\Geocoder\Model\Address $address: The address to be formatted. This (might but) is not referring to Geocoder\Location for backport compatibility with 8.x-2.x version. Third party modules might have already created their own custom formatters.

Return value

string The formatted address.

Overrides FormatterInterface::format

File

src/Plugin/Geocoder/Formatter/FormattedAddress.php, line 20

Class

FormattedAddress
Provides a Default Formatted Address plugin.

Namespace

Drupal\geocoder\Plugin\Geocoder\Formatter

Code

public function format(Address $address) {
  $formatted_address = $this->formatter
    ->format($address, '%S %n, %z %L %c, %C');

  // Clean the address, from double whitespaces, ending/starting commas, etc.
  $this
    ->cleanFormattedAddress($formatted_address);
  return $formatted_address;
}