|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Saito - The Threaded Web Forum |
|
7
|
|
|
* |
|
8
|
|
|
* @copyright Copyright (c) the Saito Project Developers |
|
9
|
|
|
* @link https://github.com/Schlaefer/Saito |
|
10
|
|
|
* @license http://opensource.org/licenses/MIT |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace App\Controller; |
|
14
|
|
|
|
|
15
|
|
|
use App\Controller\Component\ThemesComponent; |
|
16
|
|
|
use App\Controller\Component\TitleComponent; |
|
17
|
|
|
use Cake\Controller\Controller; |
|
18
|
|
|
use Cake\Core\Configure; |
|
19
|
|
|
use Cake\Event\Event; |
|
20
|
|
|
use Saito\User\CurrentUser\CurrentUserFactory; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Custom Error Controller to render errors in default theme for production. |
|
24
|
|
|
* |
|
25
|
|
|
* @property ThemesComponent $Themes |
|
26
|
|
|
* @property TitleComponent $Title |
|
27
|
|
|
*/ |
|
28
|
|
|
class ErrorController extends Controller |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritDoc} |
|
32
|
|
|
*/ |
|
33
|
|
|
public function initialize() |
|
34
|
|
|
{ |
|
35
|
|
|
parent::initialize(); |
|
36
|
|
|
|
|
37
|
|
|
$this->loadComponent('Themes', Configure::read('Saito.themes')); |
|
38
|
|
|
// Populate forum title for display in layout |
|
39
|
|
|
$this->loadComponent('Title'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* {@inheritDoc} |
|
44
|
|
|
*/ |
|
45
|
|
|
public function beforeRender(Event $event) |
|
46
|
|
|
{ |
|
47
|
|
|
parent::beforeRender($event); |
|
48
|
|
|
|
|
49
|
|
|
if (!Configure::read('debug')) { |
|
50
|
|
|
// Pickup custom errorX00.ctp layout files. |
|
51
|
|
|
$this->viewBuilder()->setTemplatePath('Error'); |
|
52
|
|
|
|
|
53
|
|
|
// Set stripped down CurrentUser so calls to it in (default) layout |
|
54
|
|
|
// .ctp(s) don't fail. |
|
55
|
|
|
$CurrentUser = CurrentUserFactory::createDummy(); |
|
56
|
|
|
$this->set('CurrentUser', $CurrentUser); |
|
57
|
|
|
|
|
58
|
|
|
$this->Themes->setDefault(); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|