|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* System warnings basic file. |
|
4
|
|
|
* |
|
5
|
|
|
* @package App |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright YetiForce S.A. |
|
8
|
|
|
* @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com) |
|
9
|
|
|
* @author Mariusz Krzaczkowski <[email protected]> |
|
10
|
|
|
* @author Radosław Skrzypczak <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace App; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* System warnings basic class. |
|
17
|
|
|
*/ |
|
18
|
|
|
class SystemWarnings |
|
19
|
|
|
{ |
|
20
|
|
|
const FOLDERS = 'app/SystemWarnings'; |
|
21
|
|
|
const SELECTED_FOLDERS = ['SystemRequirements', 'YetiForce', 'Security', 'Mail']; |
|
22
|
1 |
|
|
|
23
|
|
|
/** |
|
24
|
1 |
|
* Returns a list of folders warnings. |
|
25
|
1 |
|
* |
|
26
|
1 |
|
* @return array |
|
27
|
1 |
|
*/ |
|
28
|
1 |
|
public static function getFolders() |
|
29
|
1 |
|
{ |
|
30
|
1 |
|
$folders = []; |
|
31
|
1 |
|
$i = 0; |
|
32
|
1 |
|
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(self::FOLDERS, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) { |
|
33
|
1 |
|
if ($item->isDir()) { |
|
34
|
|
|
$subPath = $iterator->getSubPathName(); |
|
|
|
|
|
|
35
|
|
|
$fileName = $item->getFilename(); |
|
36
|
1 |
|
$subPath = str_replace(\DIRECTORY_SEPARATOR, '/', $subPath); |
|
37
|
1 |
|
$parent = rtrim(rtrim($subPath, $fileName), '/'); |
|
38
|
|
|
$folder = ['id' => $i, 'text' => Language::translate($fileName, 'Settings:SystemWarnings'), 'subPath' => $subPath, 'parent' => '#']; |
|
39
|
1 |
|
if (isset($folders[$parent])) { |
|
40
|
|
|
$folder['parent'] = $folders[$parent]['id']; |
|
41
|
1 |
|
} |
|
42
|
|
|
if (\in_array($subPath, self::SELECTED_FOLDERS)) { |
|
43
|
1 |
|
$folder['state']['selected'] = true; |
|
44
|
|
|
} |
|
45
|
|
|
$folders[$subPath] = $folder; |
|
46
|
|
|
} |
|
47
|
|
|
++$i; |
|
48
|
|
|
} |
|
49
|
|
|
return $folders; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Returns a list of warnings instance. |
|
54
|
1 |
|
* |
|
55
|
|
|
* @param array $folders |
|
56
|
1 |
|
* @param mixed $active |
|
57
|
|
|
* |
|
58
|
|
|
* @return array |
|
59
|
1 |
|
*/ |
|
60
|
1 |
|
public static function getWarnings($folders, $active = true) |
|
61
|
|
|
{ |
|
62
|
1 |
|
if (empty($folders)) { |
|
63
|
1 |
|
return []; |
|
64
|
1 |
|
} |
|
65
|
1 |
|
if (!\is_array($folders) && 'all' === $folders) { |
|
|
|
|
|
|
66
|
|
|
$folders = array_keys(static::getFolders()); |
|
67
|
|
|
} |
|
68
|
1 |
|
$actions = []; |
|
69
|
1 |
|
foreach ($folders as $folder) { |
|
70
|
1 |
|
$dir = self::FOLDERS . '/' . $folder; |
|
71
|
1 |
|
if (!is_dir($dir)) { |
|
72
|
1 |
|
continue; |
|
73
|
1 |
|
} |
|
74
|
1 |
|
$iterator = new \DirectoryIterator($dir); |
|
75
|
1 |
|
foreach ($iterator as $item) { |
|
76
|
1 |
|
if (!$item->isDot() && !$item->isDir()) { |
|
77
|
1 |
|
$fileName = $item->getBasename('.php'); |
|
78
|
1 |
|
$folder = str_replace('/', '\\', $folder); |
|
79
|
1 |
|
$className = "\\App\\SystemWarnings\\$folder\\$fileName"; |
|
80
|
|
|
$instace = new $className(); |
|
81
|
1 |
|
if ($instace->preProcess()) { |
|
82
|
1 |
|
$isIgnored = 2 === $instace->getStatusValue(); |
|
83
|
|
|
if (!$active || !$isIgnored) { |
|
84
|
1 |
|
$instace->process(); |
|
85
|
1 |
|
} |
|
86
|
1 |
|
if (!$active || (!$isIgnored && 1 !== $instace->getStatus())) { |
|
87
|
|
|
$instace->setFolder($folder); |
|
88
|
|
|
$actions[$instace->getPriority() . $fileName] = $instace; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
1 |
|
} |
|
93
|
|
|
} |
|
94
|
1 |
|
krsort($actions); |
|
95
|
|
|
|
|
96
|
|
|
return $actions; |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
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.