class EuropeanCentralBankExchanger in Commerce Exchanger 8
Provides EuropeanCentralBank.
Plugin annotation
@CommerceExchangerProvider(
id = "ecb",
label = "European Central Bank",
display_label = "European Central Bank",
historical_rates = TRUE,
base_currency = "EUR",
refresh_once = TRUE,
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider\ExchangerProviderBase implements ExchangerProviderInterface, ContainerFactoryPluginInterface
- class \Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider\ExchangerProviderRemoteBase implements ExchangerProviderRemoteInterface
- class \Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider\EuropeanCentralBankExchanger
- class \Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider\ExchangerProviderRemoteBase implements ExchangerProviderRemoteInterface
- class \Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider\ExchangerProviderBase implements ExchangerProviderInterface, ContainerFactoryPluginInterface
Expanded class hierarchy of EuropeanCentralBankExchanger
File
- src/
Plugin/ Commerce/ ExchangerProvider/ EuropeanCentralBankExchanger.php, line 19
Namespace
Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProviderView source
class EuropeanCentralBankExchanger extends ExchangerProviderRemoteBase {
/**
* {@inheritdoc}
*/
public function apiUrl() {
return 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml';
}
/**
* {@inheritdoc}
*/
public function getRemoteData($base_currency = NULL) {
$data = NULL;
$request = $this
->apiClient([]);
if ($request) {
try {
$xml = new SimpleXMLElement($request);
} catch (\Exception $e) {
$this->logger
->error($e
->getMessage());
}
$data = [];
// Loop and build array.
foreach ($xml->Cube->Cube->Cube as $rate) {
$code = (string) $rate['currency'];
$rate = (string) $rate['rate'];
$data[$code] = $rate;
}
}
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EuropeanCentralBankExchanger:: |
public | function |
URL from remote provider upon API call should be made. Overrides ExchangerProviderRemoteInterface:: |
|
EuropeanCentralBankExchanger:: |
public | function |
Fetch external data. Overrides ExchangerProviderRemoteInterface:: |
|
ExchangerProviderBase:: |
protected | property | Configuration management. | |
ExchangerProviderBase:: |
protected | property | Return formatted array of currencies ['HRK' => 'Croatian Kuna']. | |
ExchangerProviderBase:: |
protected | property | The currency storage. | |
ExchangerProviderBase:: |
private | property | Parent entity if present. | |
ExchangerProviderBase:: |
protected | property | The HTTP client to fetch the feed data with. | |
ExchangerProviderBase:: |
protected | property | The logger. | |
ExchangerProviderBase:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
|
ExchangerProviderBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
ExchangerProviderBase:: |
public | function | ||
ExchangerProviderBase:: |
public | function |
Return config object name where exchange rates are saved. Overrides ExchangerProviderInterface:: |
|
ExchangerProviderBase:: |
public | function | ||
ExchangerProviderBase:: |
protected | function | Simple key-value array for enabled currencies. | |
ExchangerProviderBase:: |
public | function | ||
ExchangerProviderBase:: |
public | function | ||
ExchangerProviderBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
ExchangerProviderBase:: |
public | function | ||
ExchangerProviderBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
ExchangerProviderBase:: |
public | function |
Constructs a new ExchangeProvider object. Overrides PluginBase:: |
|
ExchangerProviderRemoteBase:: |
public | function |
Generic wrapper around Drupal http client. Overrides ExchangerProviderRemoteInterface:: |
|
ExchangerProviderRemoteBase:: |
protected | function | Process all currencies for rates for other currencies. | |
ExchangerProviderRemoteBase:: |
protected | function | Rates calculation for currencies when we use cross sync conversion. | |
ExchangerProviderRemoteBase:: |
public | function |
Remote providers api key. Overrides ExchangerProviderRemoteInterface:: |
|
ExchangerProviderRemoteBase:: |
public | function |
Remote authentication credentials. Overrides ExchangerProviderRemoteInterface:: |
|
ExchangerProviderRemoteBase:: |
public | function |
Either remote provider defined base currency, or use entered. Overrides ExchangerProviderRemoteInterface:: |
|
ExchangerProviderRemoteBase:: |
public | function |
Method which supports remote provider. Overrides ExchangerProviderRemoteInterface:: |
|
ExchangerProviderRemoteBase:: |
public | function | ||
ExchangerProviderRemoteBase:: |
protected | function | Preform cross conversion between currencies to build exchange data rates. | |
ExchangerProviderRemoteBase:: |
protected | function | Fetch remote provider by each currency and create dataset. | |
ExchangerProviderRemoteBase:: |
public | function |
Determine if remote provider supports querying by different base currency. Overrides ExchangerProviderRemoteInterface:: |
|
ExchangerProviderRemoteBase:: |
protected | function | Helper function to create array for exchange rates. | |
ExchangerProviderRemoteBase:: |
protected | function | Process data with checking structure and preparing data for importing. | |
ExchangerProviderRemoteBase:: |
protected | function | Recalculate currencies from exchange rate between two other currencies. | |
ExchangerProviderRemoteBase:: |
public | function |
Determine if rates provided by provider needs to be transformed
in a required rate ratio based on base currency. Overrides ExchangerProviderRemoteInterface:: |
|
ExchangerProviderRemoteBase:: |
public | function |
Either remote provider defined or use defined choice. Overrides ExchangerProviderRemoteInterface:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. |