Completed
Push — master ( c228f5...68ff1f )
by Iurii
01:24
created

Main::getTranslationModel()   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 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
        $this->checkJqueryVersion($result);
66
    }
67
68
    /**
69
     * Implements hook "module.enable.after"
70
     */
71
    public function hookModuleEnableAfter()
72
    {
73
        $this->library->clearCache();
74
    }
75
76
    /**
77
     * Implements hook "module.disable.after"
78
     */
79
    public function hookModuleDisableAfter()
80
    {
81
        $this->library->clearCache();
82
    }
83
84
    /**
85
     * Implements hook "module.install.after"
86
     */
87
    public function hookModuleInstallAfter()
88
    {
89
        $this->library->clearCache();
90
    }
91
92
    /**
93
     * Implements hook "module.uninstall.after"
94
     */
95
    public function hookModuleUninstallAfter()
96
    {
97
        $this->library->clearCache();
98
    }
99
100
    /**
101
     * Check Jquery version
102
     * @param mixed $result
103
     */
104
    protected function checkJqueryVersion(&$result)
105
    {
106
        $library = $this->library->get('jquery');
107
108
        if (version_compare($library['version'], '1.8.0', '<')) {
109
            $result = gplcart_text('Jquery Mobile requires Jquery >= 1.8.0');
110
        }
111
    }
112
113
}
114