1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* The MIT License (MIT) |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2015 zepi |
6
|
|
|
* |
7
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
8
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
9
|
|
|
* in the Software without restriction, including without limitation the rights |
10
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
12
|
|
|
* furnished to do so, subject to the following conditions: |
13
|
|
|
* |
14
|
|
|
* The above copyright notice and this permission notice shall be included in |
15
|
|
|
* all copies or substantial portions of the Software. |
16
|
|
|
* |
17
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23
|
|
|
* THE SOFTWARE. |
24
|
|
|
* |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The abstract ModuleAbstract is the base for all modules |
29
|
|
|
* |
30
|
|
|
* @package Zepi\Turbo\Module |
31
|
|
|
* @author Matthias Zobrist <[email protected]> |
32
|
|
|
* @copyright Copyright (c) 2015 zepi |
33
|
|
|
*/ |
34
|
|
|
|
35
|
|
|
namespace Zepi\Turbo\Module; |
36
|
|
|
|
37
|
|
|
use \Zepi\Turbo\Framework; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The abstract ModuleAbstract is the base for all modules |
41
|
|
|
* |
42
|
|
|
* @author Matthias Zobrist <[email protected]> |
43
|
|
|
* @copyright Copyright (c) 2015 zepi |
44
|
|
|
*/ |
45
|
|
|
abstract class ModuleAbstract |
46
|
|
|
{ |
47
|
|
|
/** |
48
|
|
|
* @access protected |
49
|
|
|
* @var Framework |
50
|
|
|
*/ |
51
|
|
|
protected $framework; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @access protected |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
protected $namespace; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @access protected |
61
|
|
|
* @var string |
62
|
|
|
*/ |
63
|
|
|
protected $directory; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Constructs the object |
67
|
|
|
* |
68
|
|
|
* @access public |
69
|
|
|
* @param \Zepi\Turbo\Framework $framework |
70
|
|
|
* @param string $namespace |
71
|
|
|
* @param string $directory |
72
|
|
|
*/ |
73
|
12 |
|
public function __construct(Framework $framework, $namespace, $directory) |
74
|
|
|
{ |
75
|
12 |
|
$this->framework = $framework; |
76
|
12 |
|
$this->namespace = $namespace; |
77
|
12 |
|
$this->directory = $directory; |
78
|
12 |
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Initializes the module |
82
|
|
|
* |
83
|
|
|
* @access public |
84
|
|
|
*/ |
85
|
|
|
public function initialize() |
86
|
|
|
{ |
87
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Initializes and return an instance of the given class name. |
92
|
|
|
* |
93
|
|
|
* @access public |
94
|
|
|
* @param string $className |
95
|
|
|
* @return mixed |
96
|
|
|
*/ |
97
|
|
|
public function getInstance($className) |
98
|
|
|
{ |
99
|
|
|
return $this->framework->initiateObject($className); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* This action will be executed on the activation of the module |
104
|
|
|
* |
105
|
|
|
* @access public |
106
|
|
|
* @abstract |
107
|
|
|
* @param string $versionNumber |
108
|
|
|
* @param string $oldVersionNumber |
109
|
|
|
*/ |
110
|
|
|
abstract public function activate($versionNumber, $oldVersionNumber = ''); |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* This action will be executed on the deactiviation of the module |
114
|
|
|
* |
115
|
|
|
* @access public |
116
|
|
|
*/ |
117
|
|
|
public function deactivate() |
118
|
|
|
{ |
119
|
|
|
|
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Returns the namespace of the module |
124
|
|
|
* |
125
|
|
|
* @access public |
126
|
|
|
* @return string |
127
|
|
|
*/ |
128
|
4 |
|
public function getNamespace() |
129
|
|
|
{ |
130
|
4 |
|
return $this->namespace; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Returns the directory of the module |
135
|
|
|
* |
136
|
|
|
* @access public |
137
|
|
|
* @return string |
138
|
|
|
*/ |
139
|
4 |
|
public function getDirectory() |
140
|
|
|
{ |
141
|
4 |
|
return $this->directory; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|