Completed
Push — master ( 7feff4...723e59 )
by Iurii
01:48
created

Currency::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * @package Currency
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2017, Iurii Makukh <[email protected]>
7
 * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License 3.0
8
 */
9
10
namespace gplcart\modules\currency;
11
12
use gplcart\core\Module;
13
14
/**
15
 * Main class for Currency module
16
 */
17
class Currency extends Module
18
{
19
20
    /**
21
     * Constructor
22
     */
23
    public function __construct()
24
    {
25
        parent::__construct();
26
    }
27
28
    /**
29
     * Implements hook "module.install.before"
30
     */
31
    public function hookModuleInstallBefore(&$result)
32
    {
33
        if (!function_exists('curl_init')) {
34
            $result = 'CURL library is not enabled';
35
        }
36
    }
37
38
    /**
39
     * Implements hook "route.list"
40
     * @param array $routes
41
     */
42
    public function hookRouteList(array &$routes)
43
    {
44
        // Module settings page
45
        $routes['admin/module/settings/currency'] = array(
46
            'access' => 'module_edit',
47
            'handlers' => array(
48
                'controller' => array('gplcart\\modules\\currency\\controllers\\Settings', 'editSettings')
49
            )
50
        );
51
    }
52
53
    /**
54
     * Implements hook "cron"
55
     */
56
    public function hookCron()
57
    {
58
        $settings = $this->config->module('currency');
59
60
        if (!empty($settings['status'])) {
61
            /* @var $model \gplcart\modules\currency\models\Currency */
62
            $currency = $this->getInstance('gplcart\\modules\\currency\\models\\Currency');
63
            $currency->setSettings($settings);
64
            $currency->update();
65
        }
66
    }
67
68
}
69