Passed
Push — master ( 510786...275623 )
by Fran
04:26
created

Admin::getMenu()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
abstract class Admin extends AuthAdminController
19
{
20
21
    const DOMAIN = 'ROOT';
22
23
    /**
24
     * @Inyectable
25
     * @var \PSFS\base\config\Config Configuration service
26
     */
27
    protected $config;
28
    /**
29
     * @Inyectable
30
     * @var \PSFS\services\AdminServices Admin service
31
     */
32
    protected $srv;
33
34
    /**
35
     * Método estático de login de administrador
36
     * @param string $route
0 ignored issues
show
Documentation introduced by
Should the type for parameter $route not be string|null?

This check looks for @param annotations 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.

Loading history...
37
     * @return string HTML
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
38
     * @throws \PSFS\base\exception\FormException
39
     */
40 1
    public static function staticAdminLogon($route = null)
41
    {
42 1
        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
43
            if ('login' !== Config::getInstance()->get('admin_login')) {
44
                return AdminServices::getInstance()->setAdminHeaders();
45
            } else {
46
                $form = new LoginForm();
47
                $form->setData(array("route" => $route));
48
                $form->build();
49
                $tpl = Template::getInstance();
50
                $tpl->setPublicZone(true);
51
                return $tpl->render("login.html.twig", array(
52
                    'form' => $form,
53
                ));
54
            }
55
        } else {
56 1
            return UserController::showAdminManager();
57
        }
58
    }
59
60
    /**
61
     * Método que gestiona el menú de administración
62
     * @GET
63
     * @route /admin
64
     * @visible false
65
     * @return string|null
66
     */
67
    public function index()
68
    {
69
        return $this->render("index.html.twig");
70
    }
71
72
}
73