From 1617ea1a4ba732b1a2ebd3f109fa539bff521db3 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Mon, 6 Jan 2025 19:43:15 +0100 Subject: [PATCH 1/2] add docs for ORM patchable rename --- en/appendices/6-0-migration-guide.rst | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/en/appendices/6-0-migration-guide.rst b/en/appendices/6-0-migration-guide.rst index 73d5aed08b..719f611389 100644 --- a/en/appendices/6-0-migration-guide.rst +++ b/en/appendices/6-0-migration-guide.rst @@ -20,8 +20,26 @@ Behavior Changes Breaking Changes ================ +Datasource +---------- + +- ``Datasource/Paging/PaginatedInterface`` now extends ``IteratorAggregate`` + instead of ``Traversable``. + +ORM +--- + +- The ``_accessible`` property inside Entities has been renamed to ``patchable`` + to better reflect its purpose. +- ``setAccess`` method has been renamed to ``setPatchable``. +- ``getAccessible`` method has been renamed to ``getPatchable``. +- ``isAccessible`` method has been renamed to ``isPatchable``. +- The ``accessibleFields`` option used in e.g. ORM Queries has been + renamed to ``patchableFields``. + +Utility +------- + - The default placeholder format for ``Text::insert()`` has been changed. They now use ``{foo}`` instead of ``:foo``. You can get the old behavior by using the ``before`` and ``after`` keys of ``$options``. -- ``Datasource/Paging/PaginatedInterface`` now extends ``IteratorAggregate`` - instead of ``Traversable``. From d16b738f3d333ddf01bb234f12a43de7700f5905 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 7 Jan 2025 16:19:15 -0500 Subject: [PATCH 2/2] Update usage of changed accessible fields. --- en/orm/behaviors/translate.rst | 2 +- en/orm/entities.rst | 12 ++++++------ en/orm/saving-data.rst | 12 ++++++------ en/tutorials-and-examples/cms/articles-model.rst | 4 ++-- en/tutorials-and-examples/cms/authorization.rst | 2 +- en/tutorials-and-examples/cms/tags-and-users.rst | 2 +- en/views/helpers/form.rst | 2 +- es/tutorials-and-examples/blog-auth-example/auth.rst | 2 +- es/tutorials-and-examples/cms/database.rst | 4 ++-- fr/orm/behaviors/translate.rst | 2 +- fr/orm/entities.rst | 12 ++++++------ fr/orm/saving-data.rst | 12 ++++++------ fr/tutorials-and-examples/blog-auth-example/auth.rst | 2 +- fr/tutorials-and-examples/bookmarks/part-two.rst | 6 +++--- fr/tutorials-and-examples/cms/authorization.rst | 2 +- fr/tutorials-and-examples/cms/database.rst | 4 ++-- fr/tutorials-and-examples/cms/tags-and-users.rst | 2 +- fr/views/helpers/form.rst | 2 +- ja/orm/behaviors/translate.rst | 2 +- ja/orm/entities.rst | 12 ++++++------ ja/orm/saving-data.rst | 12 ++++++------ ja/tutorials-and-examples/blog-auth-example/auth.rst | 2 +- ja/tutorials-and-examples/bookmarks/part-two.rst | 6 +++--- ja/tutorials-and-examples/cms/database.rst | 4 ++-- ja/tutorials-and-examples/cms/tags-and-users.rst | 2 +- pt/orm/entities.rst | 6 +++--- pt/orm/saving-data.rst | 12 ++++++------ pt/tutorials-and-examples/blog-auth-example/auth.rst | 2 +- pt/tutorials-and-examples/bookmarks/part-two.rst | 6 +++--- pt/tutorials-and-examples/cms/database.rst | 4 ++-- 30 files changed, 78 insertions(+), 78 deletions(-) diff --git a/en/orm/behaviors/translate.rst b/en/orm/behaviors/translate.rst index 9a0f8f90a2..e1f839bd51 100644 --- a/en/orm/behaviors/translate.rst +++ b/en/orm/behaviors/translate.rst @@ -501,7 +501,7 @@ In your controller, you can marshal the data as normal:: This will result in your article, the french and spanish translations all being persisted. You'll need to remember to add ``_translations`` into the -``$_accessible`` fields of your entity as well. +``$patchable`` fields of your entity as well. Validating Translated Entities ------------------------------ diff --git a/en/orm/entities.rst b/en/orm/entities.rst index 8eadeea6e0..c5eb58fdc8 100644 --- a/en/orm/entities.rst +++ b/en/orm/entities.rst @@ -361,7 +361,7 @@ into an entity allows the user to modify any and all columns. When using anonymous entity classes or creating the entity class with the :doc:`/bake` CakePHP does not protect against mass-assignment. -The ``_accessible`` property allows you to provide a map of fields and +The ``patchable`` property allows you to provide a map of fields and whether or not they can be mass-assigned. The values ``true`` and ``false`` indicate whether a field can or cannot be mass-assigned:: @@ -371,7 +371,7 @@ indicate whether a field can or cannot be mass-assigned:: class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true ]; @@ -386,7 +386,7 @@ fallback behavior if a field is not specifically named:: class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true, '*' => false, @@ -408,14 +408,14 @@ protect itself against mass assignment:: Modifying the Guarded Fields at Runtime --------------------------------------- -You can modify the list of guarded fields at runtime using the ``setAccess()`` +You can modify the list of guarded fields at runtime using the ``setPatchable()`` method:: // Make user_id accessible. - $article->setAccess('user_id', true); + $article->setPatchable('user_id', true); // Make title guarded. - $article->setAccess('title', false); + $article->setPatchable('title', false); .. note:: diff --git a/en/orm/saving-data.rst b/en/orm/saving-data.rst index c6145ec6c4..a194023bf8 100644 --- a/en/orm/saving-data.rst +++ b/en/orm/saving-data.rst @@ -139,7 +139,7 @@ one or many entities from request data. You can convert a single entity using:: If you are using newEntity() and the resulting entities are missing some or all of the data they were passed, double check that the columns you want to - set are listed in the ``$_accessible`` property of your entity. See :ref:`entities-mass-assignment`. + set are listed in the ``$patchable`` property of your entity. See :ref:`entities-mass-assignment`. The request data should follow the structure of your entities. For example if you have an article, which belonged to a user, and had many comments, your @@ -365,8 +365,8 @@ Changing Accessible Fields -------------------------- It's also possible to allow ``newEntity()`` to write into non accessible fields. -For example, ``id`` is usually absent from the ``_accessible`` property. In -such case, you can use the ``accessibleFields`` option. It could be useful to +For example, ``id`` is usually absent from the ``patchable`` property. In +such case, you can use the ``patchableFields`` option. It could be useful to keep ids of associated entities:: // In a controller @@ -377,7 +377,7 @@ keep ids of associated entities:: 'Tags', 'Comments' => [ 'associated' => [ 'Users' => [ - 'accessibleFields' => ['id' => true], + 'patchableFields' => ['id' => true], ], ], ], @@ -391,7 +391,7 @@ concerned entity. If you are using newEntity() and the resulting entities are missing some or all of the data they were passed, double check that the columns you want to - set are listed in the ``$_accessible`` property of your entity. See + set are listed in the ``$patchable`` property of your entity. See :ref:`entities-mass-assignment`. Merging Request Data Into Entities @@ -482,7 +482,7 @@ an important caveat: If a Product belongsToMany Tag:: // in the Product Entity - protected array $_accessible = [ + protected array $patchable = [ // .. other properties 'tags' => true, ]; diff --git a/en/tutorials-and-examples/cms/articles-model.rst b/en/tutorials-and-examples/cms/articles-model.rst index e3415640dc..85bd126953 100644 --- a/en/tutorials-and-examples/cms/articles-model.rst +++ b/en/tutorials-and-examples/cms/articles-model.rst @@ -58,7 +58,7 @@ look like this:: class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'user_id' => true, 'title' => true, 'slug' => true, @@ -71,7 +71,7 @@ look like this:: ]; } -Right now, our entity is quite slim; we've only set up the ``_accessible`` +Right now, our entity is quite slim; we've only set up the ``patchable`` property, which controls how properties can be modified by :ref:`entities-mass-assignment`. diff --git a/en/tutorials-and-examples/cms/authorization.rst b/en/tutorials-and-examples/cms/authorization.rst index 41a0194ec5..e00d8596d6 100644 --- a/en/tutorials-and-examples/cms/authorization.rst +++ b/en/tutorials-and-examples/cms/authorization.rst @@ -225,7 +225,7 @@ Next we'll update the ``edit`` action. Replace the edit method with the followin if ($this->request->is(['post', 'put'])) { $this->Articles->patchEntity($article, $this->request->getData(), [ // Added: Disable modification of user_id. - 'accessibleFields' => ['user_id' => false] + 'patchableFields' => ['user_id' => false] ]); if ($this->Articles->save($article)) { $this->Flash->success(__('Your article has been updated.')); diff --git a/en/tutorials-and-examples/cms/tags-and-users.rst b/en/tutorials-and-examples/cms/tags-and-users.rst index be51a717cf..28867c4618 100644 --- a/en/tutorials-and-examples/cms/tags-and-users.rst +++ b/en/tutorials-and-examples/cms/tags-and-users.rst @@ -336,7 +336,7 @@ can add a virtual/computed field to the entity. In use Cake\Collection\Collection; // Update the accessible property to contain `tag_string` - protected array $_accessible = [ + protected array $patchable = [ //other fields... 'tag_string' => true ]; diff --git a/en/views/helpers/form.rst b/en/views/helpers/form.rst index 3cc3980c8a..ed368720bf 100644 --- a/en/views/helpers/form.rst +++ b/en/views/helpers/form.rst @@ -1563,7 +1563,7 @@ to your form's view template file:: is displayed, the value inside will be empty. To prevent the ``submittedfile`` from being over-written as blank, remove it -from ``$_accessible``. Alternatively, you can unset the index by using +from ``$patchable``. Alternatively, you can unset the index by using ``beforeMarshal``:: public function beforeMarshal(\Cake\Event\EventInterface $event, \ArrayObject $data, \ArrayObject $options) diff --git a/es/tutorials-and-examples/blog-auth-example/auth.rst b/es/tutorials-and-examples/blog-auth-example/auth.rst index 8480565e4a..2774047356 100644 --- a/es/tutorials-and-examples/blog-auth-example/auth.rst +++ b/es/tutorials-and-examples/blog-auth-example/auth.rst @@ -157,7 +157,7 @@ archivo de la entidad **src/Model/Entity/User.php** y añade lo siguiente:: class User extends Entity { // Make all fields mass assignable except for primary key field "id". - protected array $_accessible = [ + protected array $patchable = [ '*' => true, 'id' => false ]; diff --git a/es/tutorials-and-examples/cms/database.rst b/es/tutorials-and-examples/cms/database.rst index 29c74cc43f..20634dd6a9 100644 --- a/es/tutorials-and-examples/cms/database.rst +++ b/es/tutorials-and-examples/cms/database.rst @@ -208,7 +208,7 @@ archivo completo debería verse así:: class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true, 'published' => true, @@ -219,7 +219,7 @@ archivo completo debería verse así:: } Nuestra entidad es bastante delgada en este momento, y solo hemos configurado -la propiedad ``_accessible`` que controla cómo las propiedades pueden ser +la propiedad ``patchable`` que controla cómo las propiedades pueden ser modificadas por `entities-mass-assignment`. No podemos hacer mucho con nuestros modelos en este momento, así que a continuación diff --git a/fr/orm/behaviors/translate.rst b/fr/orm/behaviors/translate.rst index 149383bac9..57d35c42f6 100644 --- a/fr/orm/behaviors/translate.rst +++ b/fr/orm/behaviors/translate.rst @@ -471,7 +471,7 @@ avec l'option ``translations`` activée:: Ceci va faire que votre article, les traductions françaises et espagnoles vont tous persister. Vous devrez aussi vous souvenir d'ajouter ``_translations`` -dans les champs accessibles ``$_accessible`` de votre entity. +dans les champs accessibles ``$patchable`` de votre entity. Valider les Entities Traduites ------------------------------ diff --git a/fr/orm/entities.rst b/fr/orm/entities.rst index 6edc6b3eb4..45f2dc4eca 100644 --- a/fr/orm/entities.rst +++ b/fr/orm/entities.rst @@ -388,7 +388,7 @@ toutes). Utiliser des classes entity anonymes ou créer des classes entity avec la commande :doc:`/bake` de CakePHP ne protège pas contre l'assignement en masse. -La propriété ``_accessible`` vous permet de fournir une liste des champs et +La propriété ``patchable`` vous permet de fournir une liste des champs et d'indiquer s'ils peuvent être assignés en masse ou non. Les valeurs ``true`` et ``false`` indiquent si un champ peut ou ne peut pas être assigné massivement:: @@ -398,7 +398,7 @@ d'indiquer s'ils peuvent être assignés en masse ou non. Les valeurs ``true`` e class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true ]; @@ -413,7 +413,7 @@ comportement par défaut si un champ n'est pas nommé spécifiquement:: class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true, '*' => false, @@ -436,13 +436,13 @@ Modifier les Champs Protégés à la Volée --------------------------------------- Vous pouvez modifier à la volée la liste des champs protégés en utilisant la -méthode ``setAccess()``:: +méthode ``setPatchable()``:: // Rendre user_id accessible. - $article->setAccess('user_id', true); + $article->setPatchable('user_id', true); // Rendre title protégé. - $article->setAccess('title', false); + $article->setPatchable('title', false); .. note:: diff --git a/fr/orm/saving-data.rst b/fr/orm/saving-data.rst index 3cbe63f5af..d1b4b2b334 100644 --- a/fr/orm/saving-data.rst +++ b/fr/orm/saving-data.rst @@ -147,7 +147,7 @@ données de la requête. Vous pouvez convertir une entity unique en utilisant:: Si vous utilisez newEntity() et qu'il manque tout ou partie des nouvelles données dans les entities créées, vérifiez que les colonnes que vous voulez - modifier sont listées dans la propriété ``$_accessible`` de votre entity. + modifier sont listées dans la propriété ``$patchable`` de votre entity. Cf. :ref:`entities-mass-assignment`. Les données de la requête doivent suivre la structure de vos entities. Par @@ -388,8 +388,8 @@ Changer les Champs Accessibles Il est également possible d'autoriser ``newEntity()`` à écrire dans des champs non accessibles. Par exemple, ``id`` est généralement absent de la -propriété ``_accessible``. Dans un tel cas, vous pouvez utiliser l'option -``accessibleFields``. Il pourrait être utile de conserver les ids des entities +propriété ``patchable``. Dans un tel cas, vous pouvez utiliser l'option +``patchableFields``. Il pourrait être utile de conserver les ids des entities associées:: // Dans un controller. @@ -400,7 +400,7 @@ associées:: 'Tags', 'Comments' => [ 'associated' => [ 'Users' => [ - 'accessibleFields' => ['id' => true], + 'patchableFields' => ['id' => true], ], ], ], @@ -414,7 +414,7 @@ l'entity concernée. Si vous utilisez newEntity() et qu'il manque dans l'entity tout ou partie des données transmises, vérifiez à deux fois que les colonnes - que vous souhaitez définir sont listées dans la propriété ``$_accessible`` + que vous souhaitez définir sont listées dans la propriété ``$patchable`` de votre entity. Cf. :ref:`entities-mass-assignment`. Fusionner les Données de la Requête dans les Entities @@ -506,7 +506,7 @@ belongsToMany, avec cependant un point d'attention important: Si Product belongsToMany Tag:: // Dans l'entity Product - protected array $_accessible = [ + protected array $patchable = [ // .. autres propriétés 'tags' => true, ]; diff --git a/fr/tutorials-and-examples/blog-auth-example/auth.rst b/fr/tutorials-and-examples/blog-auth-example/auth.rst index f31ca57ca4..67f4ca1bcb 100755 --- a/fr/tutorials-and-examples/blog-auth-example/auth.rst +++ b/fr/tutorials-and-examples/blog-auth-example/auth.rst @@ -166,7 +166,7 @@ suit:: { // Rend les champs assignables en masse sauf pour la clé primaire "id". - protected array $_accessible = [ + protected array $patchable = [ '*' => true, 'id' => false ]; diff --git a/fr/tutorials-and-examples/bookmarks/part-two.rst b/fr/tutorials-and-examples/bookmarks/part-two.rst index c486403ab7..1df0e24a14 100644 --- a/fr/tutorials-and-examples/bookmarks/part-two.rst +++ b/fr/tutorials-and-examples/bookmarks/part-two.rst @@ -346,13 +346,13 @@ pouvons ajouter un champ virtuel/calculé à l'entity. Dans Cela nous laissera l'accès à la propriété calculée ``$bookmark->tag_string``. Nous utiliserons cette propriété dans controls plus tard. Rappelez-vous -d'ajouter la propriété ``tag_string`` dans la liste ``_accessible`` de votre +d'ajouter la propriété ``tag_string`` dans la liste ``patchable`` de votre entity, puisque nous voulons la 'sauvegarder' plus tard. Dans le fichier **src/Model/Entity/Bookmark.php**, ajoutez ``tag_string`` à -la propriété ``_accessible`` comme ceci:: +la propriété ``patchable`` comme ceci:: - protected array $_accessible = [ + protected array $patchable = [ 'user_id' => true, 'title' => true, 'description' => true, diff --git a/fr/tutorials-and-examples/cms/authorization.rst b/fr/tutorials-and-examples/cms/authorization.rst index 7d2f0456ab..0b228aec67 100644 --- a/fr/tutorials-and-examples/cms/authorization.rst +++ b/fr/tutorials-and-examples/cms/authorization.rst @@ -222,7 +222,7 @@ Ensuite nous allons modifier l'action ``edit``. Remplacez la méthode d'édition if ($this->request->is(['post', 'put'])) { $this->Articles->patchEntity($article, $this->request->getData(), [ // Ajout: Empêcher la modification de user_id. - 'accessibleFields' => ['user_id' => false] + 'patchableFields' => ['user_id' => false] ]); if ($this->Articles->save($article)) { $this->Flash->success(__('Votre article a été sauvegardé.')); diff --git a/fr/tutorials-and-examples/cms/database.rst b/fr/tutorials-and-examples/cms/database.rst index afd3e834dc..81969f70d4 100644 --- a/fr/tutorials-and-examples/cms/database.rst +++ b/fr/tutorials-and-examples/cms/database.rst @@ -214,7 +214,7 @@ Le fichier devra ressembler à ceci:: class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ '*' => true, 'id' => false, 'slug' => false, @@ -222,7 +222,7 @@ Le fichier devra ressembler à ceci:: } Notre entity est assez simple pour l'instant et nous y avons seulement défini la -propriété ``_accessible`` qui permet de contrôler quelles propriétés peuvent être +propriété ``patchable`` qui permet de contrôler quelles propriétés peuvent être modifiées via :ref:`entities-mass-assignment`. Pour l'instant, nous ne pouvons pas faire grande chose avec notre model. Pour diff --git a/fr/tutorials-and-examples/cms/tags-and-users.rst b/fr/tutorials-and-examples/cms/tags-and-users.rst index ef1f5b45e3..f2dd79a6ef 100644 --- a/fr/tutorials-and-examples/cms/tags-and-users.rst +++ b/fr/tutorials-and-examples/cms/tags-and-users.rst @@ -346,7 +346,7 @@ entity, nous ajoutons un champ virtuel/pré-calculé pour l'entity. Dans use Cake\Collection\Collection; // Mettez à jour la propriété accessible pour qu'elle contienne `tag_string` - protected array $_accessible = [ + protected array $patchable = [ //autres champs... 'tag_string' => true ]; diff --git a/fr/views/helpers/form.rst b/fr/views/helpers/form.rst index 76f4aed552..249f7fd3c0 100644 --- a/fr/views/helpers/form.rst +++ b/fr/views/helpers/form.rst @@ -1582,7 +1582,7 @@ Ensuite ajoutez l'une des deux lignes dans votre formulaire:: À chaque affichage du formulaire, la valeur sera vide. Pour empêcher le ``submittedfile`` d'être écrasé par un contenu vide, enlevez-le -de ``$_accessible``. Au choix, vous pouvez aussi retirer sa clé depuis la +de ``$patchable``. Au choix, vous pouvez aussi retirer sa clé depuis la méthode ``beforeMarshal``:: public function beforeMarshal(\Cake\Event\EventInterface $event, \ArrayObject $data, \ArrayObject $options) diff --git a/ja/orm/behaviors/translate.rst b/ja/orm/behaviors/translate.rst index 458bab2103..316125a213 100644 --- a/ja/orm/behaviors/translate.rst +++ b/ja/orm/behaviors/translate.rst @@ -438,7 +438,7 @@ TranslateBehavior の背後にある哲学は、デフォルトの言語を表 $this->Articles->save($article); これは、すべてが永続化されたフランス語とスペイン語の翻訳の記事になります。 -同様に、エンティティーの ``$_accessible`` フィールドの中に +同様に、エンティティーの ``$patchable`` フィールドの中に ``_translations`` を追加することを忘れないでください。 翻訳されたエンティティーの検証 diff --git a/ja/orm/entities.rst b/ja/orm/entities.rst index 7ff2db1dda..bed5c3986b 100644 --- a/ja/orm/entities.rst +++ b/ja/orm/entities.rst @@ -309,7 +309,7 @@ CakePHP の ORM を使うためにエンティティークラスを生成する 匿名のエンティティークラスを使ったり、 :doc:`/bake` でエンティティーを生成すると、 CakePHP は一括代入から保護しません。 -``_accessible`` プロパティーにより、プロパティーと一括代入できるかどうかのマップを提供できるようになります。 +``patchable`` プロパティーにより、プロパティーと一括代入できるかどうかのマップを提供できるようになります。 ``true`` と ``false`` の値はそれぞれ、その列が一括代入できるか、できないかを示しています。 :: namespace App\Model\Entity; @@ -318,7 +318,7 @@ CakePHP は一括代入から保護しません。 class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true ]; @@ -333,7 +333,7 @@ CakePHP は一括代入から保護しません。 class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true, '*' => false, @@ -354,13 +354,13 @@ CakePHP は一括代入から保護しません。 保護されたフィールドを実行時に変更する ---------------------------------------- -``setAccess()`` メソッドを使うことで保護されたフィールドのリストを実行時に変更できます。 :: +``setPatchable()`` メソッドを使うことで保護されたフィールドのリストを実行時に変更できます。 :: // user_id にアクセスできるようにする - $article->setAccess('user_id', true); + $article->setPatchable('user_id', true); // title を保護する。 - $article->setAccess('title', false); + $article->setPatchable('title', false); .. note:: diff --git a/ja/orm/saving-data.rst b/ja/orm/saving-data.rst index ecb6e278a1..48aef18d97 100644 --- a/ja/orm/saving-data.rst +++ b/ja/orm/saving-data.rst @@ -143,7 +143,7 @@ Table クラスは、リクエストデータを一つまたは複数のエン もし newEntity() を使っていて、返されてきたエンティティーが渡したデータのいくつか またはすべてを失っている場合は、設定したいカラムがそのエンティティーの - ``$_accessible`` プロパティーに列挙されているかをもう一度確認してみてください。 + ``$patchable`` プロパティーに列挙されているかをもう一度確認してみてください。 :ref:`entities-mass-assignment` をご覧ください。 リクエストデータはあなたのエンティティーの構造に従っていなければなりません。 @@ -370,8 +370,8 @@ belongsToMany の変換を ``_ids`` キーの使用のみに制限して、他 ------------------------------ ``newEntity()`` に、アクセス不可能なフィールドに書き込ませることもできます。 -例えば ``id`` は通常は ``_accessible`` プロパティーから外れます。 -そうした場合には、 ``accessibleFields`` オプションを使うことができます。 +例えば ``id`` は通常は ``patchable`` プロパティーから外れます。 +そうした場合には、 ``patchableFields`` オプションを使うことができます。 これは関連付けられたエンティティーの ID を維持するために便利かもしれません。 :: // コントローラーの中で @@ -382,7 +382,7 @@ belongsToMany の変換を ``_ids`` キーの使用のみに制限して、他 'Tags', 'Comments' => [ 'associated' => [ 'Users' => [ - 'accessibleFields' => ['id' => true], + 'patchableFields' => ['id' => true], ], ], ], @@ -396,7 +396,7 @@ belongsToMany の変換を ``_ids`` キーの使用のみに制限して、他 もし newEntity() を使っていて、返されてきたエンティティーが渡したデータのいくつか またはすべてを失っている場合は、設定したいカラムがそのエンティティーの - ``$_accessible`` プロパティーに列挙されているかをもう一度確認してみてください。 + ``$patchable`` プロパティーに列挙されているかをもう一度確認してみてください。 :ref:`entities-mass-assignment` をご覧ください。 リクエストデータをエンティティーにマージ @@ -484,7 +484,7 @@ hasMany の belongsToMany アソシエーションについても同じことが もし、 Product belongsToMany Tag であれば、こうなります。 :: // Product エンティティーの中で - protected array $_accessible = [ + protected array $patchable = [ // .. 他のプロパティー 'tags' => true, ]; diff --git a/ja/tutorials-and-examples/blog-auth-example/auth.rst b/ja/tutorials-and-examples/blog-auth-example/auth.rst index 2656a098d6..328f7813b1 100644 --- a/ja/tutorials-and-examples/blog-auth-example/auth.rst +++ b/ja/tutorials-and-examples/blog-auth-example/auth.rst @@ -140,7 +140,7 @@ composerを使ってAuthenticationプラグインをインストールします class User extends Entity { // 主キーフィールドである「id」以外のすべてのフィールドを一括代入可能にします。 - protected array $_accessible = [ + protected array $patchable = [ '*' => true, 'id' => false ]; diff --git a/ja/tutorials-and-examples/bookmarks/part-two.rst b/ja/tutorials-and-examples/bookmarks/part-two.rst index 1856bf02e2..ce54b83602 100644 --- a/ja/tutorials-and-examples/bookmarks/part-two.rst +++ b/ja/tutorials-and-examples/bookmarks/part-two.rst @@ -323,12 +323,12 @@ AppController に追加しましょう。 :: 計算済みのプロパティー ``$bookmark->tag_string`` にアクセスできるようになります。 このプロパティーはあとで入力時に使用します。 あとで保存するので ``tag_string`` プロパティーを -エンティティーの ``_accessible`` リストに追加することを忘れないでください。 +エンティティーの ``patchable`` リストに追加することを忘れないでください。 -**src/Model/Entity/Bookmark.php** で ``$_accessible`` に ``tag_string`` を +**src/Model/Entity/Bookmark.php** で ``$patchable`` に ``tag_string`` を このように追加してください。 :: - protected array $_accessible = [ + protected array $patchable = [ 'user_id' => true, 'title' => true, 'description' => true, diff --git a/ja/tutorials-and-examples/cms/database.rst b/ja/tutorials-and-examples/cms/database.rst index 3a80dc1d1a..c2b986110c 100644 --- a/ja/tutorials-and-examples/cms/database.rst +++ b/ja/tutorials-and-examples/cms/database.rst @@ -154,7 +154,7 @@ Table オブジェクトを ``ArticlesTable`` と名付けることで、CakePHP class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true, 'published' => true, @@ -165,7 +165,7 @@ Table オブジェクトを ``ArticlesTable`` と名付けることで、CakePHP } エンティティーは、今はとてもスリムです。そして、 :ref:`entities-mass-assignment` によって -どのようにプロパティーを変更できるかを制御するプロパティー ``_accessible`` をセットアップしました。 +どのようにプロパティーを変更できるかを制御するプロパティー ``patchable`` をセットアップしました。 このモデルは、今は動きませんが、次は最初の :doc:`コントローラーとテンプレート ` diff --git a/ja/tutorials-and-examples/cms/tags-and-users.rst b/ja/tutorials-and-examples/cms/tags-and-users.rst index d72f4b9523..3cb25504cb 100644 --- a/ja/tutorials-and-examples/cms/tags-and-users.rst +++ b/ja/tutorials-and-examples/cms/tags-and-users.rst @@ -322,7 +322,7 @@ CakePHP では、コントローラーのアクションをスリムに保ち、 use Cake\Collection\Collection; // アクセス可能なプロパティに `tag_string` を含めるよう更新します - protected array $_accessible = [ + protected array $patchable = [ // その他のフィールドも追加可能 'tag_string' => true ]; diff --git a/pt/orm/entities.rst b/pt/orm/entities.rst index f27dcb5385..fce416787d 100644 --- a/pt/orm/entities.rst +++ b/pt/orm/entities.rst @@ -288,7 +288,7 @@ usuário apartir da requisição a uma entidade permite ao usuário modificar to quaisquer colunas. Ao usar classes de entidade anônimas ou criar a classe de entidade com :doc:`/bake`, o CakePHP não protege contra a atribuição em massa. -A propriedade ``_accessible`` permite que você forneça um mapa de propriedades +A propriedade ``patchable`` permite que você forneça um mapa de propriedades e se elas podem ou não ser atribuídas em massa. Os valores ``true`` e ``false`` indicam se um campo pode ou não ser atribuído em massa:: @@ -298,7 +298,7 @@ indicam se um campo pode ou não ser atribuído em massa:: class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true ]; @@ -313,7 +313,7 @@ de falbback se um campo não for especificamente nomeado:: class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ 'title' => true, 'body' => true, '*' => false, diff --git a/pt/orm/saving-data.rst b/pt/orm/saving-data.rst index d782132d81..53f24dbda9 100644 --- a/pt/orm/saving-data.rst +++ b/pt/orm/saving-data.rst @@ -186,7 +186,7 @@ usando::   Se você estiver usando newEntity() e as entidades resultantes estão faltando algum ou todos os dados passados, verifique se as colunas que deseja definir estão - listadas na propriedade ``$_accessible`` da sua entidade. Consulte :ref:`entities-mass-assignment`. + listadas na propriedade ``$patchable`` da sua entidade. Consulte :ref:`entities-mass-assignment`. Os dados da requisição devem seguir a estrutura de suas entidades. Por exemplo, se você tem um artigo, que pertence a um usuário, e tem muitos comentários, os seus dados de @@ -415,8 +415,8 @@ Alterando Campos Acessíveis --------------------------- Também é possível permitir ``newEntity()`` escrever em campos não acessiveis. -Por exemplo, ``id`` geralmente está ausente da propriedade ``_accessible``. -Nesse caso , você pode usar a opção ``accessibleFields``. Isso pode ser útil para +Por exemplo, ``id`` geralmente está ausente da propriedade ``patchable``. +Nesse caso , você pode usar a opção ``patchableFields``. Isso pode ser útil para manter ids de entidades associadas:: // No controller @@ -428,7 +428,7 @@ manter ids de entidades associadas:: 'Tags', 'Comments' => [ 'associated' => [ 'Users' => [ - 'accessibleFields' => ['id' => true] + 'patchableFields' => ['id' => true] ] ] ] @@ -442,7 +442,7 @@ entidade envolvida. Se você estiver usando newEntity() e as entidades resultantes estão faltando algum ou todos os dados passados, verifique se as colunas que deseja definir estão - listadas na propriedade ``$_accessible`` da sua entidade. Consulte :ref:`entities-mass-assignment`. + listadas na propriedade ``$patchable`` da sua entidade. Consulte :ref:`entities-mass-assignment`. Mesclando Dados de Requisição em Entidades ------------------------------------------ @@ -532,7 +532,7 @@ advertência importante: Se um Produto pertence a várias (belongsToMany) Tag:: // Na classe da entidade Product - protected array $_accessible = [ + protected array $patchable = [ // .. outras propriedades 'tags' => true, ]; diff --git a/pt/tutorials-and-examples/blog-auth-example/auth.rst b/pt/tutorials-and-examples/blog-auth-example/auth.rst index 9f3cb94f4a..320994cd16 100644 --- a/pt/tutorials-and-examples/blog-auth-example/auth.rst +++ b/pt/tutorials-and-examples/blog-auth-example/auth.rst @@ -229,7 +229,7 @@ e adicione a seguinte trecho:: { // Gera conjunto de todos os campos exceto o com a chave primária. - protected array $_accessible = [ + protected array $patchable = [ '*' => true, 'id' => false ]; diff --git a/pt/tutorials-and-examples/bookmarks/part-two.rst b/pt/tutorials-and-examples/bookmarks/part-two.rst index 1db885160b..07e0fbc483 100644 --- a/pt/tutorials-and-examples/bookmarks/part-two.rst +++ b/pt/tutorials-and-examples/bookmarks/part-two.rst @@ -328,12 +328,12 @@ entidade. Em **src/Model/Entity/Bookmark.php** adicione o seguinte:: Isso vai nos deixar acessar a propriedade computada ``$bookmark->tag_string``. Vamos usar essa propriedade em inputs mais tarde. Lembre-se de adicionar a -propriedade ``tag_string`` a lista ``_accessible`` em sua entidade. +propriedade ``tag_string`` a lista ``patchable`` em sua entidade. Em **src/Model/Entity/Bookmark.php** adicione o ``tag_string`` ao -``_accessible`` desta forma:: +``patchable`` desta forma:: - protected array $_accessible = [ + protected array $patchable = [ 'user_id' => true, 'title' => true, 'description' => true, diff --git a/pt/tutorials-and-examples/cms/database.rst b/pt/tutorials-and-examples/cms/database.rst index 925cb5b54b..86feab24cc 100644 --- a/pt/tutorials-and-examples/cms/database.rst +++ b/pt/tutorials-and-examples/cms/database.rst @@ -225,7 +225,7 @@ com este:: class Article extends Entity { - protected array $_accessible = [ + protected array $patchable = [ '*' => true, 'id' => false, 'slug' => false, @@ -233,7 +233,7 @@ com este:: } Nossa entidade está bem curta agora, e nós iremos configurar apenas a -propriedade ``_accessible`` que controla quais propriedades podem ser +propriedade ``patchable`` que controla quais propriedades podem ser modificadas com :ref:`entities-mass-assignment`. Nós não podemos fazer muito com nossos modelos agora, então a seguir