Completed
Push — master ( 68ff1f...7354a9 )
by Iurii
01:09
created

Main::checkJqueryVersion()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
/**
4
 * @package Jquery Mobile
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 GPL-3.0+
8
 */
9
10
namespace gplcart\modules\jquery_mobile;
11
12
use gplcart\core\Library;
13
14
/**
15
 * Main class for Jquery Mobile module
16
 */
17
class Main
18
{
19
20
    /**
21
     * Library class instance
22
     * @var \gplcart\core\Library $library
23
     */
24
    protected $library;
25
26
    /**
27
     * @param Library $library
28
     */
29
    public function __construct(Library $library)
30
    {
31
        $this->library = $library;
32
    }
33
34
    /**
35
     * Implements hook "library.list"
36
     * @param array $libraries
37
     */
38
    public function hookLibraryList(array &$libraries)
39
    {
40
        $libraries['jquery_mobile'] = array(
41
            'name' => 'Jquery Mobile', // @text
42
            'description' => 'A HTML5-based user interface system designed to make responsive web sites and apps that are accessible on all smartphone, tablet and desktop devices', // @text
43
            'type' => 'asset',
44
            'module' => 'jquery_mobile',
45
            'url' => 'http://jquerymobile.com',
46
            'download' => 'http://jquerymobile.com/resources/download/jquery.mobile-1.4.5.zip',
47
            'version_source' => array(
48
                'file' => 'vendor/jquery/jquery-mobile/jquery.mobile-1.4.5.min.js',
49
                'pattern' => '/jQuery Mobile (\\d+\\.+\\d+\\.+\\d+)/',
50
                'lines' => 2
51
            ),
52
            'files' => array(
53
                'vendor/jquery/jquery-mobile/jquery.mobile-1.4.5.min.js',
54
                'vendor/jquery/jquery-mobile/jquery.mobile-1.4.5.min.css'
55
            ),
56
        );
57
    }
58
59
    /**
60
     * Implements hook "module.install.before"
61
     * @param null|string
62
     */
63
    public function hookModuleInstallBefore(&$result)
64
    {
65
        $library = $this->library->get('jquery');
66
67
        if (empty($library['version']) || version_compare($library['version'], '1.8.0', '<')) {
68
            $result = gplcart_text('Jquery Mobile requires Jquery >= 1.8.0');
69
        }
70
    }
71
72
    /**
73
     * Implements hook "module.enable.after"
74
     */
75
    public function hookModuleEnableAfter()
76
    {
77
        $this->library->clearCache();
78
    }
79
80
    /**
81
     * Implements hook "module.disable.after"
82
     */
83
    public function hookModuleDisableAfter()
84
    {
85
        $this->library->clearCache();
86
    }
87
88
    /**
89
     * Implements hook "module.install.after"
90
     */
91
    public function hookModuleInstallAfter()
92
    {
93
        $this->library->clearCache();
94
    }
95
96
    /**
97
     * Implements hook "module.uninstall.after"
98
     */
99
    public function hookModuleUninstallAfter()
100
    {
101
        $this->library->clearCache();
102
    }
103
104
}
105