Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions ja/controllers/components/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ Security コンポーネントのフォーム保護機能と、 ``startup()``

public function beforeFilter(Event $event)
{
$this->Security->config('blackHoleCallback', 'blackhole');
$this->Security->setConfig('blackHoleCallback', 'blackhole');
}

public function blackhole($type)
{
// エラー処理
}

注意: CakePHP バージョン 3.4 より前の場合、 ``$this->Security->config()`` を使用してください。

``$type`` パラメーターは、以下の値を指定できます。

* 'auth' は、フォームバリデーションエラー、もしくはコントローラー/アクションの不適合エラーを示します。
Expand Down Expand Up @@ -99,7 +101,8 @@ allowedActions
これは、コントローラー間リクエストの制御に利用できます。

これらの設定オプションを使用すると、コントローラー間の通信を制限することができます。
それらは、 ``config()`` メソッドで設定します。
それらは、 ``setConfig()`` メソッドで設定します。
もし CakePHP バージョン 3.4 より前を使用している場合は ``config()`` です。

フォーム改ざん防止
==================
Expand Down Expand Up @@ -131,7 +134,7 @@ validatePost
``false`` をセットすると、POST リクエストのバリデーションを完全にスキップし、
実質フォームバリデーションを無効化します。

上記の設定オプションは、 ``config()`` で設定することができます。
上記の設定オプションは、 ``setConfig()`` で設定することができます。

使い方
======
Expand Down Expand Up @@ -229,10 +232,12 @@ CSRF 保護機能を有効にするには、 :doc:`/controllers/components/csrf`

public function beforeFilter(Event $event)
{
$this->Security->config('unlockedActions', ['edit']);
$this->Security->setConfig('unlockedActions', ['edit']);
}
}

注意: CakePHP バージョン 3.4.0 より前の場合、 ``$this->Security->config()`` を使用してください。

この例では、edit アクションのすべてのセキュリティチェックが無効になります。

.. meta::
Expand Down
2 changes: 1 addition & 1 deletion ja/orm/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ CakePHP の ORM を使うためにエンティティークラスを生成する
これにより、エラーメッセージで動くコードのテストが簡単になります。 ::

$user->setError('password', ['Password is required']);
$user->setErrors(['pasword' => ['Password is required'], 'username' => ['Username is required']]);
$user->setErrors(['password' => ['Password is required'], 'username' => ['Username is required']]);
// 3.4.0 より前
$user->errors('password', ['Password is required.']);

Expand Down
7 changes: 7 additions & 0 deletions ja/orm/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ CakePHP は、エンティティーが保存される前に適用される「ル
// タグは3つ以上、5つ以内
$rules->add($rules->validCount('tags', 3, '>=', 'タグは 3 つ以上必要です'));
$rules->add($rules->validCount('tags', 5, '<=', 'タグは 5 つ以下です'));
$rules->add($rules->validCount('subscription', 0, '==', '購読してません'));

.. note::

そのプロパティーが数えられない場合や存在しない場合、 ``validCount`` は ``false`` を返します。
例えば、上記の例で言うと、subscription は少なくとも空のリストになっていなければ、``<`` や
``<=`` による比較や ``0`` と比較する場合に ``false`` を返します。

.. versionadded:: 3.3.0
``validCount()`` メソッドは、3.3.0 で追加されました。
Expand Down