-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrency_switcher_fixer_io.module
33 lines (30 loc) · 1.18 KB
/
currency_switcher_fixer_io.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
* @file
* Current foreign exchanges rates published by the European Central Bank.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function currency_switcher_fixer_io_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.currency_switcher_fixer_io':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('<p>A simple module provides the Foreign exchange rates and currency conversion API <a>Fixer.io</a></p>
<p>You can select the necessary currencies from the list.</p>');
return $output;
}
}
/**
* Implements hook_cron.
*/
function currency_switcher_fixer_io_cron() {
$service = \Drupal::service('currency_switcher_fixer_io.controller');
$config_setting = \Drupal::service('config.factory')->getEditable('currency_switcher_fixer_io.settings')->get('settings');
$config_setting = implode(",", $config_setting);
$base = $service->currencyCheck($config_setting);
$config = \Drupal::service('config.factory')->getEditable('currency_switcher_fixer_io.currency');
$config->set('currency', $base)->save();
}