1
|
|
|
<?php namespace Comodojo\Extender\Utils; |
2
|
|
|
|
3
|
|
|
use \Comodojo\Foundation\Base\Configuration; |
4
|
|
|
use \Comodojo\Extender\Components\Database; |
5
|
|
|
use \Exception; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @package Comodojo Extender |
9
|
|
|
* @author Marco Giovinazzi <[email protected]> |
10
|
|
|
* @license MIT |
11
|
|
|
* |
12
|
|
|
* LICENSE: |
13
|
|
|
* |
14
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
17
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
18
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
19
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
20
|
|
|
* THE SOFTWARE. |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
class Checks { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Check if script is running from command line |
27
|
|
|
* |
28
|
|
|
* @return bool |
29
|
|
|
*/ |
30
|
|
|
final public static function cli() { |
31
|
|
|
|
32
|
|
|
return php_sapi_name() === 'cli'; |
33
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Check if php interpreter supports pcntl_fork (required in multithread mode) |
38
|
|
|
* |
39
|
|
|
* @return bool |
40
|
|
|
*/ |
41
|
|
|
final public static function multithread() { |
42
|
|
|
|
43
|
|
|
return function_exists("pcntl_fork"); |
44
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Check if php interpreter supports pcntl signal handlers |
49
|
|
|
* |
50
|
|
|
* @return bool |
51
|
|
|
*/ |
52
|
|
|
final public static function signals() { |
53
|
|
|
|
54
|
|
|
return function_exists("pcntl_signal"); |
55
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Check if database is available and initialized correctly |
60
|
|
|
* |
61
|
|
|
* @return bool |
62
|
|
|
*/ |
63
|
|
|
final public static function database(Configuration $configuration) { |
64
|
|
|
|
65
|
|
|
try { |
66
|
|
|
|
67
|
|
|
$dbh = Database::init($configuration); |
68
|
|
|
|
69
|
|
|
$dbh->connect(); |
|
|
|
|
70
|
|
|
|
71
|
|
|
$manager = $dbh->getSchemaManager(); |
|
|
|
|
72
|
|
|
|
73
|
|
|
$manager->getTable($configuration->get('database-jobs-table')); |
74
|
|
|
$manager->getTable($configuration->get('database-worklogs-table')); |
75
|
|
|
$manager->getTable($configuration->get('database-queue-table')); |
76
|
|
|
|
77
|
|
|
} catch (Exception $e) { |
78
|
|
|
|
79
|
|
|
return false; |
80
|
|
|
|
81
|
|
|
} finally { |
82
|
|
|
|
83
|
|
|
$dhb->close(); |
|
|
|
|
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return true; |
88
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.