Completed
Push — master ( a65a6c...a5c595 )
by Iurii
04:08
created

Zopim   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hookRouteList() 0 10 1
A hookConstructControllerFrontend() 0 11 4
1
<?php
2
3
/**
4
 * @package Zopim
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\zopim;
11
12
use gplcart\core\Module;
13
14
/**
15
 * Main class for Zopim module
16
 */
17
class Zopim 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/zopim'] = array(
36
            'access' => 'module_edit',
37
            'handlers' => array(
38
                'controller' => array('gplcart\\modules\\zopim\\controllers\\Settings', 'editSettings')
39
            )
40
        );
41
    }
42
43
    /**
44
     * Implements hook "construct.controller.frontend"
45
     * @param \gplcart\core\controllers\frontend\Controller $controller
46
     */
47
    public function hookConstructControllerFrontend($controller)
48
    {
49
        $settings = $this->config->module('zopim');
50
51
        if (!empty($settings['code'])//
52
                && (empty($settings['trigger_id'])//
53
                || $controller->isTriggered($settings['trigger_id']))) {
54
            $options = array('position' => 'bottom', 'aggregate' => false);
55
            $controller->setJs($settings['code'], $options);
56
        }
57
    }
58
59
}
60