nuxsmin /
sysPass
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * sysPass |
||
| 4 | * |
||
| 5 | * @author nuxsmin |
||
| 6 | * @link https://syspass.org |
||
| 7 | * @copyright 2012-2019, 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 DI\DependencyException; |
||
| 29 | use DI\NotFoundException; |
||
| 30 | use Klein\Klein; |
||
| 31 | use SP\Core\Exceptions\FileNotFoundException; |
||
| 32 | use SP\Core\Exceptions\SPException; |
||
| 33 | use SP\Modules\Web\Controllers\Helpers\LayoutHelper; |
||
| 34 | use SP\Mvc\View\Template; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Class ErrorController |
||
| 38 | * |
||
| 39 | * @package SP\Modules\Web\Controllers |
||
| 40 | */ |
||
| 41 | final class ErrorController |
||
| 42 | { |
||
| 43 | /** |
||
| 44 | * @var Template |
||
| 45 | */ |
||
| 46 | protected $view; |
||
| 47 | /** |
||
| 48 | * @var Klein |
||
| 49 | */ |
||
| 50 | protected $router; |
||
| 51 | /** |
||
| 52 | * @var LayoutHelper |
||
| 53 | */ |
||
| 54 | protected $layoutHelper; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * ErrorController constructor. |
||
| 58 | * |
||
| 59 | * @param Container $container |
||
| 60 | * @param string $actionName |
||
| 61 | * |
||
| 62 | * @throws DependencyException |
||
| 63 | * @throws NotFoundException |
||
| 64 | */ |
||
| 65 | public function __construct(Container $container, $actionName) |
||
|
0 ignored issues
–
show
|
|||
| 66 | { |
||
| 67 | $this->router = $container->get(Klein::class); |
||
| 68 | |||
| 69 | $this->view = $container->get(Template::class); |
||
| 70 | $this->view->setBase('error'); |
||
| 71 | |||
| 72 | $this->layoutHelper = $container->get(LayoutHelper::class); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * indexAction |
||
| 77 | */ |
||
| 78 | public function indexAction() |
||
| 79 | { |
||
| 80 | $this->layoutHelper->getPublicLayout('error'); |
||
| 81 | $this->view(); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Mostrar los datos de la plantilla |
||
| 86 | */ |
||
| 87 | protected function view() |
||
| 88 | { |
||
| 89 | try { |
||
| 90 | echo $this->view->render(); |
||
| 91 | } catch (FileNotFoundException $e) { |
||
| 92 | processException($e); |
||
| 93 | |||
| 94 | echo __($e->getMessage()); |
||
| 95 | } |
||
| 96 | |||
| 97 | die(); |
||
|
0 ignored issues
–
show
|
|||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * databaseErrorAction |
||
| 102 | */ |
||
| 103 | public function maintenanceErrorAction() |
||
| 104 | { |
||
| 105 | $this->layoutHelper->getPublicLayout('error-maintenance'); |
||
| 106 | |||
| 107 | $this->view->append('errors', [ |
||
| 108 | 'type' => SPException::WARNING, |
||
| 109 | 'description' => __('Application on maintenance'), |
||
| 110 | 'hint' => __('It will be running shortly') |
||
| 111 | ]); |
||
| 112 | |||
| 113 | $this->view(); |
||
| 114 | } |
||
| 115 | |||
| 116 | /** |
||
| 117 | * databaseErrorAction |
||
| 118 | */ |
||
| 119 | public function databaseErrorAction() |
||
| 120 | { |
||
| 121 | $this->layoutHelper->getPublicLayout('error-database'); |
||
| 122 | |||
| 123 | $this->view->append('errors', [ |
||
| 124 | 'type' => SPException::CRITICAL, |
||
| 125 | 'description' => __('Error while checking the database'), |
||
| 126 | 'hint' => __('Please contact to the administrator') |
||
| 127 | ]); |
||
| 128 | |||
| 129 | $this->view(); |
||
| 130 | } |
||
| 131 | |||
| 132 | /** |
||
| 133 | * databaseErrorAction |
||
| 134 | */ |
||
| 135 | public function databaseConnectionAction() |
||
| 136 | { |
||
| 137 | $this->layoutHelper->getPublicLayout('error-database'); |
||
| 138 | |||
| 139 | $this->view->append('errors', [ |
||
| 140 | 'type' => SPException::CRITICAL, |
||
| 141 | 'description' => __('Unable to connect to DB'), |
||
| 142 | 'hint' => __('Please contact to the administrator') |
||
| 143 | ]); |
||
| 144 | |||
| 145 | $this->view(); |
||
| 146 | } |
||
| 147 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.