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

Zopim::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 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