Loading src/Form/ExchangeRatesBlockForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use Drupal\Core\State\StateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Class ExchangeRatesBlockForm. * Form that displays Exchange Rates block. */ class ExchangeRatesBlockForm extends FormBase { /** Loading src/Form/ExchangeRatesSettingsForm.php +2 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; /** * Class ExchangeRatesSettingsForm. * Config form to set base and conversion currencies. */ class ExchangeRatesSettingsForm extends ConfigFormBase { Loading Loading @@ -182,7 +182,7 @@ class ExchangeRatesSettingsForm extends ConfigFormBase { $config->save(); // Confirmation on form submission. drupal_set_message($this->t('The Exchange Rates settings have been saved.')); $this->messenger()->addStatus($this->t('The Exchange Rates settings have been saved.')); } } src/Plugin/Block/ExchangeRatesBlock.php +7 −5 Original line number Diff line number Diff line Loading @@ -106,12 +106,14 @@ class ExchangeRatesBlock extends BlockBase implements ContainerFactoryPluginInte $conversion_currencies = $config->get('conversion_currency'); // exchangeratesapi.io API call to fetch exchange rates for base currency. try { $response = json_decode($this->httpClient->get('https://api.exchangeratesapi.io/latest?base=' . $base_currency)->getBody()); $rates = []; if (!empty($response) && !empty($response->rates)) { $rates = $response->rates; } catch (RequestException $e) { watchdog_exception('exchange_rates', $e->getMessage()); } $rates = (!empty($response) && !empty($response->rates)) ? $response->rates : []; // Store conversion currency rates in state. foreach ($rates as $conversion_currency => $rate) { Loading Loading
src/Form/ExchangeRatesBlockForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use Drupal\Core\State\StateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Class ExchangeRatesBlockForm. * Form that displays Exchange Rates block. */ class ExchangeRatesBlockForm extends FormBase { /** Loading
src/Form/ExchangeRatesSettingsForm.php +2 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; /** * Class ExchangeRatesSettingsForm. * Config form to set base and conversion currencies. */ class ExchangeRatesSettingsForm extends ConfigFormBase { Loading Loading @@ -182,7 +182,7 @@ class ExchangeRatesSettingsForm extends ConfigFormBase { $config->save(); // Confirmation on form submission. drupal_set_message($this->t('The Exchange Rates settings have been saved.')); $this->messenger()->addStatus($this->t('The Exchange Rates settings have been saved.')); } }
src/Plugin/Block/ExchangeRatesBlock.php +7 −5 Original line number Diff line number Diff line Loading @@ -106,12 +106,14 @@ class ExchangeRatesBlock extends BlockBase implements ContainerFactoryPluginInte $conversion_currencies = $config->get('conversion_currency'); // exchangeratesapi.io API call to fetch exchange rates for base currency. try { $response = json_decode($this->httpClient->get('https://api.exchangeratesapi.io/latest?base=' . $base_currency)->getBody()); $rates = []; if (!empty($response) && !empty($response->rates)) { $rates = $response->rates; } catch (RequestException $e) { watchdog_exception('exchange_rates', $e->getMessage()); } $rates = (!empty($response) && !empty($response->rates)) ? $response->rates : []; // Store conversion currency rates in state. foreach ($rates as $conversion_currency => $rate) { Loading