Completed
Push — master ( bd9698...04e514 )
by Iurii
02:12
created

Currency::hookRouteList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
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 "route.list"
30
     * @param array $routes
31
     */
32
    public function hookRouteList(array &$routes)
33
    {
34
        // Module settings page
35
        $routes['admin/module/settings/currency'] = array(
36
            'access' => 'module_edit',
37
            'handlers' => array(
38
                'controller' => array('gplcart\\modules\\currency\\controllers\\Settings', 'editSettings')
39
            )
40
        );
41
    }
42
43
    /**
44
     * Implements hook "cron"
45
     */
46
    public function hookCron()
47
    {
48
        $settings = $this->config->module('currency');
49
50
        if (!empty($settings['status'])) {
51
            /* @var $model \gplcart\modules\currency\models\Currency */
52
            $currency = $this->getInstance('gplcart\\modules\\currency\\models\\Currency');
53
            $currency->setSettings($settings);
54
            $currency->update();
55
        }
56
    }
57
58
}
59