teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードの追加

2017/07/23 01:58

投稿

ragna
ragna

スコア12

title CHANGED
File without changes
body CHANGED
@@ -20,4 +20,58 @@
20
20
 
21
21
  どうもこうも、この様よ!
22
22
 
23
- 必要なことがあれば、コメントください。
23
+ 必要なことがあれば、コメントください。
24
+
25
+ ```ここに言語を入力
26
+ // src/Template/Error/Error500.ctp
27
+ <?php
28
+ use Cake\Core\Configure;
29
+ use Cake\Error\Debugger;
30
+ ?>
31
+ <!-- 以下content -->
32
+ <h1><span class="fui-alert-circle"></span> 500 Fatal Error</h1>
33
+ <p>技術的な問題が発生ました。</p>
34
+ <p>管理者に通報してください。</p>
35
+
36
+ // src/Template/Error/Error404.ctp
37
+ <?php
38
+ use Cake\Core\Configure;
39
+ use Cake\Error\Debugger;
40
+ ?>
41
+ <!-- 以下content -->
42
+ <h1><span class="fui-question-circle"></span> 404 Not Found</h1>
43
+ <p>お探しのページは一時的にアクセスできない状況にあるか、移動もしくは削除された可能性があります。</p>
44
+ <p>また、URL、ファイル名にミスタイプがないか再度ご確認ください。</p>
45
+
46
+ ```
47
+ ```
48
+ // src/Error/AppExceptionRenderer.php
49
+ <?php
50
+ namespace App\Error;
51
+
52
+ use Cake\Error\ExceptionRenderer;
53
+ use Exception;
54
+ use Cake\Log\Log;
55
+ use App\Error\AppErrorController;
56
+
57
+ class AppExceptionRenderer extends ExceptionRenderer
58
+ {
59
+ protected function _getController()
60
+ {
61
+ //オリジナルのエラーコントローラーを指定
62
+ return new AppErrorController();
63
+ }
64
+
65
+ protected function _template(Exception $exception, $method, $code)
66
+ {
67
+ //「src/Template/Error/」の下にあるTemplateファイルを参照している
68
+ $template = 'error500';
69
+ if ($code == 403) {
70
+ $template = 'error403';
71
+ } elseif ($code < 500) {
72
+ $template = 'error404';
73
+ }
74
+ return $this->template = $template;
75
+ }
76
+ }
77
+ ```