Skip to content

Commit f364c76

Browse files
committed
[ja] #3865, #3911, #4023
1 parent da95aa8 commit f364c76

File tree

3 files changed

+75
-114
lines changed

3 files changed

+75
-114
lines changed

ja/core-libraries/validation.rst

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,37 @@ CakePHP のバリデーションは、任意の配列データに対するバリ
6060
フィールドが実在することを求めます。もし、フィールドが存在していなければ、
6161
バリデーションは失敗します。 ``requirePresence()`` には4つのモードがあります:
6262

63-
* ``true`` この場合、フィールドが存在することが常に求められます。
64-
* ``false`` この場合、フィールドが存在することは必要なくなります。
65-
* ``create`` **create** 実行時にバリデーションを行う場合、このフィールドが存在することが求められます。
66-
* ``update`` **update** 実行時にバリデーションを行う場合、このフィールドが存在することが求められます。
63+
* ``true`` この場合、フィールドが存在することが常に求められます。
64+
* ``false`` この場合、フィールドが存在することは必要なくなります。
65+
* ``create`` **create** 実行時にバリデーションを行う場合、このフィールドが存在することが求められます。
66+
* ``update`` **update** 実行時にバリデーションを行う場合、このフィールドが存在することが求められます。
6767

6868
デフォルトでは、 ``true`` が用いられます。キーの存在は、 ``array_key_exists()``
6969
を用いることによりチェックされるため、 null 値は、「存在する」としてカウントされます。
7070
モードにについては、2番目のパラメーターを用いることにより設定できます。 ::
7171

7272
$validator->requirePresence('author_id', 'create');
7373

74+
もし要求するフィールドが複数ある場合、それらをリストとして定義することができます。 ::
75+
76+
// create として複数フィールドを定義
77+
$validator->requirePresence(['author_id', 'title'], 'create');
78+
79+
// 混在したモードで複数フィールドを定義
80+
$validator->requirePresence([
81+
'author_id' => [
82+
'mode' => 'create',
83+
'message' => 'An author is required.',
84+
],
85+
'published' => [
86+
'mode' => 'update',
87+
'message' => 'The published state is required.',
88+
]
89+
]);
90+
91+
.. versionadded:: 3.3.0
92+
``requirePresence()`` は、3.3.0 でフィールドの配列を受け取ります。
93+
7494
空のフィールドを認める
7595
----------------------
7696

ja/development/debugging.rst

Lines changed: 45 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,50 @@
11
デバッグ
22
########
33

4-
..
5-
Debugging is an inevitable and necessary part of any development
6-
cycle. While CakePHP doesn't offer any tools that directly connect
7-
with any IDE or editor, CakePHP does provide several tools to
8-
assist in debugging and exposing what is running under the hood of
9-
your application.
10-
114
デバッグはいかなる開発サイクルにおいても避けることのできない、必要なものです。
12-
CakePHP は IDE やエディタと直接連携するようなツールは提供しませんが、CakePHP はデバッグ作業やあなたのアプリケーション内部で何が走っているのかを探る作業を助けるためのツールをいくつか提供します。
5+
CakePHP は IDE やエディタと直接連携するようなツールは提供しませんが、
6+
CakePHP はデバッグ作業やあなたのアプリケーション内部で何が走っているのかを探る作業を
7+
助けるためのツールをいくつか提供します。
138

149
基本的なデバッグ
1510
================
1611

1712
.. php:function:: debug(mixed $var, boolean $showHtml = null, $showFrom = true)
1813
:noindex:
1914

20-
..
21-
The ``debug()`` function is a globally available function that works
22-
similarly to the PHP function ``print_r()``. The ``debug()`` function
23-
allows you to show the contents of a variable in a number of
24-
different ways. First, if you'd like data to be shown in an
25-
HTML-friendly way, set the second parameter to ``true``. The function
26-
also prints out the line and file it is originating from by
27-
default.
15+
``debug()`` 関数は PHP 関数の ``print_r()`` と同様に、グローバルに利用可能な関数です。
16+
``debug()`` 関数により、さまざまな方法で変数の内容を出力することができます。
17+
データを HTML に優しい方法で表示させたいなら、第2引数を ``true`` にしてください。
18+
この関数はまた、デフォルトで呼ばれた場所となるファイルと行番号も出力します。
2819

29-
``debug()`` 関数は PHP 関数の ``print_r()`` と同様に、グローバルに利用可能な関数です。 ``debug()`` 関数により、さまざまな方法で変数の内容を出力することができます。
30-
データを HTML に優しい方法で表示させたいなら、第2引数を ``true`` にしてください。この関数はまた、デフォルトで呼ばれた場所となるファイルと行番号も出力します。
20+
この関数からの出力は、core の ``$debug`` 変数が ``true`` の場合のみ行われます。
3121

32-
..
33-
Output from this function is only shown if the core ``$debug`` variable
34-
has been set to ``true``.
22+
.. versionadded:: 3.3.0
3523

36-
この関数からの出力は、core の ``$debug`` 変数が ``true`` の場合のみ行われます。
24+
このメソッドを呼ぶと、渡された ``$var`` を返します。例えば、return 文に
25+
このメソッドを置くことができます。例::
26+
27+
return debug($data); // 必ず $data を返します。
3728

38-
.. php:function:: stackTrace()
29+
``pr()`` や ``pj()`` もご確認ください。
3930

40-
..
41-
The ``stackTrace()`` function is available globally, and allows you to output
42-
a stack trace wherever the function is called.
31+
.. php:function:: stackTrace()
4332
44-
``stackTrace()`` 関数はグローバルに使用でき、関数がどこで呼ばれたかのスタックトレースを出力することができます。
33+
``stackTrace()`` 関数はグローバルに使用でき、関数がどこで呼ばれたかのスタックトレースを
34+
出力することができます。
4535

4636
.. php:function:: breakpoint()
4737
4838
.. versionadded:: 3.1
4939

50-
..
51-
If you have `Psysh <http://psysh.org/>`_ installed you can use this
52-
function in CLI enviroments to open an interactive console with the current
53-
local scope::
54-
55-
もし `Psysh <http://psysh.org/>`_ をインストールしている場合、この関数をCLI環境で使用することで現在のローカルスコープで対話型コンソールを開くことができます。 ::
40+
もし `Psysh <http://psysh.org/>`_ をインストールしている場合、この関数を
41+
CLI 環境で使用することで現在のローカルスコープで対話型コンソールを開くことができます。 ::
5642

5743
// 実行したいコード
5844
eval(breakpoint());
5945

60-
..
61-
Will open an interactive console that can be used to check local variables
62-
and execute other code. You can exit the interactive debugger and resume the
63-
original execution by running ``quit`` or ``q`` in the interactive session.
64-
65-
開いた対話型コンソールでローカル変数のチェックや他のコードの実行をすることができます。対話型デバッガを終了して元の処理に戻りたい時は ``quit`` か ``q`` を入力してください。
46+
開いた対話型コンソールでローカル変数のチェックや他のコードの実行をすることができます。
47+
対話型デバッガを終了して元の処理に戻りたい時は ``quit`` か ``q`` を入力してください。
6648

6749
Debugger クラスの使用
6850
========================
@@ -71,22 +53,16 @@ Debugger クラスの使用
7153
7254
.. php:class:: Debugger
7355
74-
..
75-
To use the debugger, first ensure that ``Configure::read('debug')`` is
76-
set to ``true``.
77-
78-
Debugger を使用する際にはまず、``Configure::read('debug')`` に ``true`` がセットされていることを確認してください。
56+
Debugger を使用する際にはまず、 ``Configure::read('debug')`` に
57+
``true`` がセットされていることを確認してください。
7958

8059
値の出力
8160
========
8261

8362
.. php:staticmethod:: dump($var, $depth = 3)
8463
85-
..
86-
Dump prints out the contents of a variable. It will print out all
87-
properties and methods (if any) of the supplied variable::
88-
89-
dump は変数の内容を出力します。渡された変数のすべてのプロパティと(可能なら)メソッドを出力します ::
64+
dump は変数の内容を出力します。渡された変数のすべてのプロパティと
65+
(可能なら)メソッドを出力します。 ::
9066

9167
$foo = [1,2,3];
9268

@@ -117,28 +93,19 @@ dump は変数の内容を出力します。渡された変数のすべてのプ
11793

11894
.. php:staticmethod:: log($var, $level = 7, $depth = 3)
11995
120-
..
121-
Creates a detailed stack trace log at the time of invocation. The
122-
``log()`` method prints out data similar to that done by
123-
``Debugger::dump()``, but to the debug.log instead of the output
124-
buffer. Note your **tmp** directory (and its contents) must be
125-
writable by the web server for ``log()`` to work correctly.
126-
12796
呼び出されたときに詳細なスタックトレースを生成します。
128-
``log()`` メソッドは ``Debugger::dump()`` によるものと似たデータを出力しますが、出力バッファにではなく、 debug.log に出力します。
129-
``log()`` が正常に動作するためには、あなたの **tmp** ディレクトリ(と、その中)はウェブサーバにより書き込み可能でなければならないことに気をつけてください。
97+
``log()`` メソッドは ``Debugger::dump()`` によるものと似たデータを出力しますが、
98+
出力バッファにではなく、 debug.log に出力します。 ``log()`` が正常に動作するためには、
99+
あなたの **tmp** ディレクトリ(と、その中)はウェブサーバにより
100+
書き込み可能でなければならないことに気をつけてください。
130101

131102
スタックトレースの生成
132103
======================
133104

134105
.. php:staticmethod:: trace($options)
135106
136-
..
137-
Returns the current stack trace. Each line of the trace includes
138-
the calling method, including which file and line the call
139-
originated from::
140-
141-
現在のスタックトレースを返します。トレースの各行には、呼び出しているメソッド、どこから呼ばれたかというファイルと行番号が含まれています。 ::
107+
現在のスタックトレースを返します。トレースの各行には、呼び出しているメソッド、
108+
どこから呼ばれたかというファイルと行番号が含まれています。 ::
142109

143110
// PostsController::index() の中で
144111
pr(Debugger::trace());
@@ -149,25 +116,17 @@ dump は変数の内容を出力します。渡された変数のすべてのプ
149116
Dispatcher::dispatch() - CORE/src/Routing/Dispatcher.php, line 237
150117
[main] - APP/webroot/index.php, line 84
151118

152-
..
153-
Above is the stack trace generated by calling ``Debugger::trace()`` in
154-
a controller action. Reading the stack trace bottom to top shows
155-
the order of currently running functions (stack frames).
156-
157-
上記では、コントローラのアクション内で ``Debugger::trace()`` を呼ぶことで、スタックトレースを生成しています。
119+
上記では、コントローラのアクション内で ``Debugger::trace()`` を呼ぶことで、
120+
スタックトレースを生成しています。
158121
スタックトレースは下から上へと読み、現在走っている関数(スタックフレーム)の順になっています。
159122

160123
ファイルから抜粋を取得
161124
======================
162125

163126
.. php:staticmethod:: excerpt($file, $line, $context)
164127
165-
..
166-
Grab an excerpt from the file at $path (which is an absolute
167-
filepath), highlights line number $line with $context number of
168-
lines around it. ::
169-
170-
$path(絶対パス)にあるファイルからの抜粋を取得します。$line 行目をハイライトし、$line 行目の前後 $context 行もあわせて取得します。 ::
128+
$path(絶対パス)にあるファイルからの抜粋を取得します。$line 行目をハイライトし、
129+
$line 行目の前後 $context 行もあわせて取得します。 ::
171130

172131
pr(Debugger::excerpt(ROOT . DS . LIBS . 'debugger.php', 321, 2));
173132

@@ -182,45 +141,28 @@ $path(絶対パス)にあるファイルからの抜粋を取得します。
182141
[4] => <code><span style="color: #000000"> $data = @explode("\n", file_get_contents($file));</span></code>
183142
)
184143

185-
..
186-
Although this method is used internally, it can be handy if you're
187-
creating your own error messages or log entries for custom
188-
situations.
189-
190-
このメソッドは内部的に使われているものですが、あなたが独自のエラーメッセージを生成する場合や独自の状況でログ出力する場合にも使いやすいものです。
144+
このメソッドは内部的に使われているものですが、あなたが独自のエラーメッセージを生成する場合や
145+
独自の状況でログ出力する場合にも使いやすいものです。
191146

192147
.. php:staticmethod:: Debugger::getType($var)
193148
194-
..
195-
Get the type of a variable. Objects will return their class name
196-
197149
変数の型を取得します。オブジェクトならクラス名を返します。
198150

199151
ログ出力によるデバッグ
200152
======================
201153

202-
..
203-
Logging messages is another good way to debug applications, and you can use
204-
:php:class:`Cake\\Log\\Log` to do logging in your application. All objects that
205-
use ``LogTrait`` have an instance method ``log()`` which can be used
206-
to log messages::
207-
208154
アプリケーションをデバッグするもう一つの良い方法はログメッセージです。
209-
:php:class:`Cake\\Log\\Log` を使うことで、あなたのアプリケーションでログ出力をさせることができます。
210-
``LogTrait`` を use するすべてのオブジェクトは、インスタンスメソッド ``log()`` を持っており、ログメッセージを出力するのに使えます ::
155+
:php:class:`Cake\\Log\\Log` を使うことで、あなたのアプリケーションでログ出力を
156+
させることができます。 ``LogTrait`` を利用するすべてのオブジェクトは、
157+
インスタンスメソッド ``log()`` を持っており、ログメッセージを出力するのに使えます。 ::
211158

212159
$this->log('通ったよ', 'debug');
213160

214-
..
215-
The above would write ``Got here`` into the debug log. You can use log entries
216-
to help debug methods that involve redirects or complicated loops. You can also
217-
use :php:meth:`Cake\\Log\\Log::write()` to write log messages. This method can be called
218-
statically anywhere in your application one CakeLog has been loaded::
219-
220161
上記では ``通ったよ`` がデバッグログに出力されます。
221162
ログに出力することで、リダイレクトや複雑なループを含むメソッドをデバッグしやすくなるでしょう。
222163
また、:php:meth:`Cake\\Log\\Log::write()` を使うことで、ログメッセージを書きだすことも可能です。
223-
このメソッドは CakeLog がロードされているなら static にあなたのアプリケーション内のどこからでも呼び出すことができるのです ::
164+
このメソッドは CakeLog がロードされているなら static にあなたのアプリケーション内の
165+
どこからでも呼び出すことができるのです。 ::
224166

225167
// ログを使用したいファイルの一番最初で
226168
use Cake\Log\Log;
@@ -231,18 +173,13 @@ $path(絶対パス)にあるファイルからの抜粋を取得します。
231173
Debug Kit
232174
=========
233175

234-
..
235-
DebugKit is a plugin that provides a number of good debugging tools. It
236-
primarily provides a toolbar in the rendered HTML, that provides a plethora of
237-
information about your application and the current request. See the
238-
:doc:`/debug-kit` chapter for how to install and use DebugKit.
239-
240176
DebugKit は便利なデバッグツールをたくさん提供してくれるプラグインです。
241-
まずは、レンダリングされた HTML 内にツールバーを表示して、あなたのアプリケーションや現在のリクエストについての情報を大量に提供してくれます。
177+
まずは、レンダリングされた HTML 内にツールバーを表示して、あなたのアプリケーションや
178+
現在のリクエストについての情報を大量に提供してくれます。
242179
DebugKit のインストールと使用方法については :doc:`/debug-kit` の章を見てください。
243180

244181

245182
.. meta::
246-
:title lang=ja: Debugging
183+
:title lang=ja: デバッグ
247184
:description lang=ja: Debugging CakePHP with the Debugger class, logging, basic debugging and using the DebugKit plugin.
248185
:keywords lang=ja: code excerpt,stack trace,default output,error link,default error,web requests,error report,debugger,arrays,different ways,excerpt from,cakephp,ide,options

ja/development/dispatch-filters.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
ディスパッチャーフィルター
2-
##########################
1+
ディスパッチャフィルタ
2+
######################
3+
4+
.. deprecated:: 3.3.0
5+
3.3.0 でディスパッチャフィルタは非推奨になりました。代わりに
6+
:doc:`/controllers/middleware` を使用してください。
37

48
コントローラーのコードが実行される前やクライアントからレスポンスを受けたり、ヘッダーをチューニングしたり、
59
完全なリクエストが送られるより短い時間で特別な必要最低限なAPIにアクセスする権限を設定したりするために、

0 commit comments

Comments
 (0)