質問編集履歴

1

コードの追加

2017/07/23 01:58

投稿

ragna
ragna

スコア12

test CHANGED
File without changes
test CHANGED
@@ -43,3 +43,111 @@
43
43
 
44
44
 
45
45
  必要なことがあれば、コメントください。
46
+
47
+
48
+
49
+ ```ここに言語を入力
50
+
51
+ // src/Template/Error/Error500.ctp
52
+
53
+ <?php
54
+
55
+ use Cake\Core\Configure;
56
+
57
+ use Cake\Error\Debugger;
58
+
59
+ ?>
60
+
61
+ <!-- 以下content -->
62
+
63
+ <h1><span class="fui-alert-circle"></span> 500 Fatal Error</h1>
64
+
65
+ <p>技術的な問題が発生ました。</p>
66
+
67
+ <p>管理者に通報してください。</p>
68
+
69
+
70
+
71
+ // src/Template/Error/Error404.ctp
72
+
73
+ <?php
74
+
75
+ use Cake\Core\Configure;
76
+
77
+ use Cake\Error\Debugger;
78
+
79
+ ?>
80
+
81
+ <!-- 以下content -->
82
+
83
+ <h1><span class="fui-question-circle"></span> 404 Not Found</h1>
84
+
85
+ <p>お探しのページは一時的にアクセスできない状況にあるか、移動もしくは削除された可能性があります。</p>
86
+
87
+ <p>また、URL、ファイル名にミスタイプがないか再度ご確認ください。</p>
88
+
89
+
90
+
91
+ ```
92
+
93
+ ```
94
+
95
+ // src/Error/AppExceptionRenderer.php
96
+
97
+ <?php
98
+
99
+ namespace App\Error;
100
+
101
+
102
+
103
+ use Cake\Error\ExceptionRenderer;
104
+
105
+ use Exception;
106
+
107
+ use Cake\Log\Log;
108
+
109
+ use App\Error\AppErrorController;
110
+
111
+
112
+
113
+ class AppExceptionRenderer extends ExceptionRenderer
114
+
115
+ {
116
+
117
+ protected function _getController()
118
+
119
+ {
120
+
121
+ //オリジナルのエラーコントローラーを指定
122
+
123
+ return new AppErrorController();
124
+
125
+ }
126
+
127
+
128
+
129
+ protected function _template(Exception $exception, $method, $code)
130
+
131
+ {
132
+
133
+ //「src/Template/Error/」の下にあるTemplateファイルを参照している
134
+
135
+ $template = 'error500';
136
+
137
+ if ($code == 403) {
138
+
139
+ $template = 'error403';
140
+
141
+ } elseif ($code < 500) {
142
+
143
+ $template = 'error404';
144
+
145
+ }
146
+
147
+ return $this->template = $template;
148
+
149
+ }
150
+
151
+ }
152
+
153
+ ```