|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PSFS\controller\base; |
|
4
|
|
|
|
|
5
|
|
|
use PSFS\base\config\Config; |
|
6
|
|
|
use PSFS\base\config\LoginForm; |
|
7
|
|
|
use PSFS\base\Router; |
|
8
|
|
|
use PSFS\base\Template; |
|
9
|
|
|
use PSFS\base\types\AuthAdminController; |
|
10
|
|
|
use PSFS\controller\UserController; |
|
11
|
|
|
use PSFS\services\AdminServices; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class Admin |
|
15
|
|
|
* @package PSFS\controller |
|
16
|
|
|
* @domain ROOT |
|
17
|
|
|
*/ |
|
18
|
|
|
class Admin extends AuthAdminController{ |
|
19
|
|
|
|
|
20
|
|
|
const DOMAIN = 'ROOT'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @Inyectable |
|
24
|
|
|
* @var \PSFS\base\config\Config Configuration service |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $config; |
|
27
|
|
|
/** |
|
28
|
|
|
* @Inyectable |
|
29
|
|
|
* @var \PSFS\services\AdminServices Admin service |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $srv; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Wrapper de asignación de los menus |
|
35
|
|
|
* @return array |
|
36
|
|
|
*/ |
|
37
|
|
|
protected function getMenu() { |
|
38
|
|
|
return Router::getInstance()->getAdminRoutes(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Método estático de login de administrador |
|
43
|
|
|
* @param string $route |
|
|
|
|
|
|
44
|
|
|
* @return string HTML |
|
|
|
|
|
|
45
|
|
|
* @throws \PSFS\base\exception\FormException |
|
46
|
|
|
*/ |
|
47
|
1 |
|
public static function staticAdminLogon($route = null) { |
|
48
|
1 |
|
if(file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
49
|
|
|
if('login' !== Config::getInstance()->get('admin_login')) { |
|
50
|
|
|
return AdminServices::getInstance()->setAdminHeaders(); |
|
51
|
|
|
} else { |
|
52
|
|
|
$form = new LoginForm(); |
|
53
|
|
|
$form->setData(array("route" => $route)); |
|
54
|
|
|
$form->build(); |
|
55
|
|
|
$tpl = Template::getInstance(); |
|
56
|
|
|
$tpl->setPublicZone(true); |
|
57
|
|
|
return $tpl->render("login.html.twig", array( |
|
58
|
|
|
'form' => $form, |
|
59
|
|
|
)); |
|
60
|
|
|
} |
|
61
|
|
|
} else { |
|
62
|
1 |
|
return UserController::showAdminManager(); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Método que gestiona el menú de administración |
|
68
|
|
|
* @GET |
|
69
|
|
|
* @route /admin |
|
70
|
|
|
* @visible false |
|
71
|
|
|
* @return string|null |
|
72
|
|
|
*/ |
|
73
|
|
|
public function index() { |
|
74
|
|
|
return $this->render("index.html.twig"); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.