View source
<?php
namespace Drupal\geocoder;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Geocoder\Model\Address;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class DumperBase extends PluginBase implements DumperInterface, ContainerFactoryPluginInterface {
protected $handler;
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition);
}
public function dump(Address $address) {
return $this
->getHandler()
->dump($address);
}
protected function getHandler() {
if (!isset($this->handler)) {
$definition = $this
->getPluginDefinition();
$class = $definition['handler'];
$this->handler = new $class();
}
return $this->handler;
}
}