FormatterBase.php in Geocoder 8.2
File
src/Plugin/Geocoder/Formatter/FormatterBase.php
View source
<?php
namespace Drupal\geocoder\Plugin\Geocoder\Formatter;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Geocoder\Formatter\StringFormatter;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class FormatterBase extends PluginBase implements FormatterInterface, ContainerFactoryPluginInterface {
protected $formatter;
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->formatter = new StringFormatter();
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition);
}
protected function cleanFormattedAddress(&$formatted_address) {
$formatted_address = preg_replace('/\\s+/', ' ', $formatted_address);
$formatted_address = str_replace(' ,', ',', $formatted_address);
$formatted_address = trim(trim(trim($formatted_address), ','));
}
}