Passed
Push — devel-3.0 ( 67d9a6...e0263f )
by Rubén
04:37
created

ErrorController::databaseErrorAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * sysPass
4
 *
5
 * @author    nuxsmin
6
 * @link      https://syspass.org
7
 * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
8
 *
9
 * This file is part of sysPass.
10
 *
11
 * sysPass is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation, either version 3 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * sysPass is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 *  along with sysPass.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24
25
namespace SP\Modules\Web\Controllers;
26
27
use DI\Container;
28
use Klein\Klein;
29
use SP\Core\Exceptions\FileNotFoundException;
30
use SP\Core\Exceptions\SPException;
31
use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
32
use SP\Mvc\View\Template;
33
34
/**
35
 * Class ErrorController
36
 *
37
 * @package SP\Modules\Web\Controllers
38
 */
39
final class ErrorController
40
{
41
    /**
42
     * @var Template
43
     */
44
    protected $view;
45
    /**
46
     * @var Klein
47
     */
48
    protected $router;
49
    /**
50
     * @var LayoutHelper
51
     */
52
    protected $layoutHelper;
53
54
    /**
55
     * ErrorController constructor.
56
     *
57
     * @param Container $container
58
     * @param string    $actionName
59
     *
60
     * @throws \DI\DependencyException
61
     * @throws \DI\NotFoundException
62
     */
63
    public function __construct(Container $container, $actionName)
0 ignored issues
show
Unused Code introduced by
The parameter $actionName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

63
    public function __construct(Container $container, /** @scrutinizer ignore-unused */ $actionName)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
    {
65
        $this->router = $container->get(Klein::class);
66
67
        $this->view = $container->get(Template::class);
68
        $this->view->setBase('error');
69
70
        $this->layoutHelper = $container->get(LayoutHelper::class);
71
    }
72
73
    /**
74
     * indexAction
75
     */
76
    public function indexAction()
77
    {
78
        $this->layoutHelper->getPublicLayout('error');
79
        $this->view();
80
    }
81
82
    /**
83
     * Mostrar los datos de la plantilla
84
     */
85
    protected function view()
86
    {
87
        try {
88
            echo $this->view->render();
89
        } catch (FileNotFoundException $e) {
90
            processException($e);
91
92
            echo __($e->getMessage());
93
        }
94
95
        die();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
96
    }
97
98
    /**
99
     * databaseErrorAction
100
     */
101
    public function maintenanceErrorAction()
102
    {
103
        $this->layoutHelper->getPublicLayout('error-maintenance');
104
105
        $this->view->append('errors', [
106
            'type' => SPException::WARNING,
107
            'description' => __('Aplicación en mantenimiento'),
108
            'hint' => __('En breve estará operativa')
109
        ]);
110
111
        $this->view();
112
    }
113
114
    /**
115
     * databaseErrorAction
116
     */
117
    public function databaseErrorAction()
118
    {
119
        $this->layoutHelper->getPublicLayout('error-database');
120
121
        $this->view->append('errors', [
122
            'type' => SPException::CRITICAL,
123
            'description' => __('Error en la verificación de la base de datos'),
124
            'hint' => __('Consulte con el administrador')
125
        ]);
126
127
        $this->view();
128
    }
129
130
    /**
131
     * databaseErrorAction
132
     */
133
    public function databaseConnectionAction()
134
    {
135
        $this->layoutHelper->getPublicLayout('error-database');
136
137
        $this->view->append('errors', [
138
            'type' => SPException::CRITICAL,
139
            'description' => __('No es posible conectar con la BD'),
140
            'hint' => __('Consulte con el administrador')
141
        ]);
142
143
        $this->view();
144
    }
145
}