1 | <?php |
||
10 | class AdminServices extends Service |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @Injectable |
||
15 | * @var \PSFS\base\config\Config Servicio de configuración |
||
16 | */ |
||
17 | protected $config; |
||
18 | /** |
||
19 | * @Injectable |
||
20 | * @var \PSFS\base\Security Servicio de autenticación |
||
21 | */ |
||
22 | protected $security; |
||
23 | /** |
||
24 | * @Injectable |
||
25 | * @var \PSFS\base\Template Servicio de gestión de plantillas |
||
26 | */ |
||
27 | protected $tpl; |
||
28 | |||
29 | /** |
||
30 | * Servicio que devuelve las cabeceras de autenticación |
||
31 | * @return string HTML |
||
32 | */ |
||
33 | public function setAdminHeaders() |
||
34 | { |
||
35 | $platform = trim(Config::getInstance()->get("platform.name")); |
||
36 | header('HTTP/1.1 401 Unauthorized'); |
||
37 | header('WWW-Authenticate: Basic Realm="' . $platform . '"'); |
||
38 | echo _("Zona restringida"); |
||
39 | exit(); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Servicio que devuelve los administradores de la plataforma |
||
44 | * @return array|mixed |
||
45 | */ |
||
46 | 1 | public function getAdmins() |
|
57 | |||
58 | /** |
||
59 | * Servicio que parsea los administradores para mostrarlos en la gestión de usuarios |
||
60 | * @param array $admins |
||
61 | */ |
||
62 | 1 | private function parseAdmins(&$admins) |
|
63 | { |
||
64 | 1 | if (!empty($admins)) foreach ($admins as &$admin) { |
|
65 | if (isset($admin["profile"])) { |
||
66 | switch ($admin["profile"]) { |
||
67 | case Security::MANAGER_ID_TOKEN: |
||
68 | $admin['class'] = 'warning'; |
||
69 | break; |
||
70 | case Security::ADMIN_ID_TOKEN: |
||
71 | $admin['class'] = 'info'; |
||
72 | break; |
||
73 | default: |
||
74 | case Security::USER_ID_TOKEN: |
||
75 | $admin['class'] = 'primary'; |
||
76 | break; |
||
77 | } |
||
78 | } else { |
||
79 | $admin["class"] = "primary"; |
||
80 | } |
||
81 | } |
||
82 | 1 | } |
|
83 | |||
84 | /** |
||
85 | * Servicio que lee los logs y los formatea para listarlos |
||
86 | * @return array |
||
87 | */ |
||
88 | public function getLogFiles() |
||
108 | |||
109 | /** |
||
110 | * Servicio que parsea el fichero de log seleccionado |
||
111 | * @param string|null $selectedLog |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | public function formatLogFile($selectedLog) |
||
145 | |||
146 | /** |
||
147 | * Servicio que trata la línea del log para procesarle en el front end |
||
148 | * @param $line |
||
149 | * @param $match |
||
150 | * |
||
151 | * @return array |
||
152 | */ |
||
153 | private function parseLogLine($line, $match) |
||
193 | } |
||
194 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.