public function FixedRates::delete in Currency 8.3
Deletes an exchange rate.
Parameters
string $currency_code_from:
string $currency_code_to:
Return value
NULL
File
- src/
Plugin/ Currency/ ExchangeRateProvider/ FixedRates.php, line 108
Class
- FixedRates
- Provides manually entered exchange rates.
Namespace
Drupal\currency\Plugin\Currency\ExchangeRateProviderCode
public function delete($currency_code_from, $currency_code_to) {
$config = $this->configFactory
->getEditable('currency.exchanger.fixed_rates');
$rates = $config
->get('rates');
foreach ($rates as $i => $rate) {
if ($rate['currency_code_from'] == $currency_code_from && $rate['currency_code_to'] == $currency_code_to) {
unset($rates[$i]);
}
}
$config
->set('rates', $rates);
$config
->save();
}