Skip to content

Commit

Permalink
Merge pull request #279 from cakephp/3.x-docs
Browse files Browse the repository at this point in the history
update BeforePolicyInterface docs
  • Loading branch information
LordSimal committed Jan 28, 2024
2 parents b0b9b12 + 6ead936 commit 10739f4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/en/policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ in your policy::

namespace App\Policy;

use Authorization\IdentityInterface;
use Authorization\Policy\BeforePolicyInterface;
use Authorization\Policy\ResultInterface;

class ArticlesPolicy implements BeforePolicyInterface
{
public function before($user, $resource, $action)
public function before(?IdentityInterface $identity, mixed $resource, string $action): ResultInterface|bool|null {
{
if ($user->getOriginalData()->is_admin) {
return true;
Expand Down
6 changes: 4 additions & 2 deletions docs/es/policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Las clases de la aplicación se 'resuelven' en una clase policy coincidente.
Consulte la sección :doc:`policy-resolvers` para saber cómo se pueden resolver las policy.

Por lo general, querrá poner sus policy en **src/Policy** y usar el sufijo de clase
``Policy``. Por ahora crearemos una clase policy para la entidad `Article` en nuestra
``Policy``. Por ahora crearemos una clase policy para la entidad `Article` en nuestra
aplicación. En **src/Policy/ArticlePolicy.php** ponga el siguiente contenido::

<?php
Expand Down Expand Up @@ -111,11 +111,13 @@ en su policy::

namespace App\Policy;

use Authorization\IdentityInterface;
use Authorization\Policy\BeforePolicyInterface;
use Authorization\Policy\ResultInterface;

class ArticlesPolicy implements BeforePolicyInterface
{
public function before($user, $resource, $action)
public function before(?IdentityInterface $identity, mixed $resource, string $action): ResultInterface|bool|null {
{
if ($user->getOriginalData()->is_admin) {
return true;
Expand Down
4 changes: 3 additions & 1 deletion docs/fr/policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ policy doit implémenter ``BeforePolicyInterface``::

namespace App\Policy;

use Authorization\IdentityInterface;
use Authorization\Policy\BeforePolicyInterface;
use Authorization\Policy\ResultInterface;

class ArticlesPolicy implements BeforePolicyInterface
{
public function before($user, $resource, $action)
public function before(?IdentityInterface $identity, mixed $resource, string $action): ResultInterface|bool|null {
{
if ($user->getOriginalData()->is_admin) {
return true;
Expand Down
6 changes: 4 additions & 2 deletions docs/ja/policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ ORMオブジェクトのポリシーを作成するには ``bake`` コマンド
ポリシーのスコープ
------------------

ポリシーは認可の可否だけでなく、「スコープ」を定義することもできます。
ポリシーは認可の可否だけでなく、「スコープ」を定義することもできます。
スコープメソッドは認可の条件を適用して他のオブジェクトを変更することができます。
リストの取得を現在のユーザーに限定するときに最適です。::

Expand All @@ -105,11 +105,13 @@ ORMオブジェクトのポリシーを作成するには ``bake`` コマンド

namespace App\Policy;

use Authorization\IdentityInterface;
use Authorization\Policy\BeforePolicyInterface;
use Authorization\Policy\ResultInterface;

class ArticlesPolicy implements BeforePolicyInterface
{
public function before($user, $resource, $action)
public function before(?IdentityInterface $identity, mixed $resource, string $action): ResultInterface|bool|null {
{
if ($user->getOriginalData()->is_admin) {
return true;
Expand Down

0 comments on commit 10739f4

Please sign in to comment.