Skip to content

Commit

Permalink
[fr] follows cakephp#4468
Browse files Browse the repository at this point in the history
  • Loading branch information
cake17 committed Nov 17, 2016
1 parent 328c61f commit 3785f8b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
23 changes: 12 additions & 11 deletions en/orm/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ persisted. For example::
return ucwords($title);
}
}

The accessor would be run when getting the property through any of these two ways::

echo $user->title;
Expand All @@ -141,8 +141,8 @@ property. As you can see above, you can also use mutators to set other
calculated properties. When doing this, be careful to not introduce any loops,
as CakePHP will not prevent infinitely looping mutator methods.

Mutators allow you to convert properties as they are set, or create calculated data.
Mutators and accessors are applied when properties are read using object
Mutators allow you to convert properties as they are set, or create calculated
data. Mutators and accessors are applied when properties are read using object
notation, or using ``get()`` and ``set()``. For example::

namespace App\Model\Entity;
Expand All @@ -161,7 +161,8 @@ notation, or using ``get()`` and ``set()``. For example::

}

The mutator would be run when setting the property through any of these two ways::
The mutator would be run when setting the property through any of these two
ways::

$user->title = 'foo'; // slug is set as well
$user->set('title', 'foo'); // slug is set as well
Expand Down Expand Up @@ -204,8 +205,8 @@ Checking if an Entity Has Been Modified
.. php:method:: dirty($field = null, $dirty = null)
You may want to make code conditional based on whether or not properties have
changed in an entity. For example, you may only want to validate fields when they
change::
changed in an entity. For example, you may only want to validate fields when
they change::

// See if the title has been modified.
$article->dirty('title');
Expand All @@ -217,9 +218,9 @@ array properties::
$article->comments[] = $newComment;
$article->dirty('comments', true);

In addition you can also base your conditional code on the original property values
by using the ``getOriginal()`` method. This method will either return the original
value of the property if it has been modified or its actual value.
In addition you can also base your conditional code on the original property
values by using the ``getOriginal()`` method. This method will either return
the original value of the property if it has been modified or its actual value.

You can also check for changes to any property in the entity::

Expand Down Expand Up @@ -340,8 +341,8 @@ fields::

$article->set($properties, ['guard' => false]);

By setting the ``guard`` option to ``false``, you can ignore the accessible field
list for a single call to ``set()``.
By setting the ``guard`` option to ``false``, you can ignore the accessible
field list for a single call to ``set()``.


Checking if an Entity was Persisted
Expand Down
15 changes: 15 additions & 0 deletions fr/orm/saving-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,21 @@ pour utiliser uniquement la clé ``_ids`` et ignorer toutes les autres données.
Convertir des Données HasMany
-----------------------------

Si vous souhaitez mettre à jour les associations hasMany existantes et mettre à
jour leurs propriétés, vous devriez d'abord vous assurer que votre entity est
chargée avec l'association hasMany remplie. Vous pouvez ensuite utiliser les
données de la requête de la façon suivante::

$data = [
'title' => 'Mon titre',
'body' => 'Le texte',
'comments' => [
['id' => 1, 'comment' => 'Mettre à jour le premier commentaire'],
['id' => 2, 'comment' => 'Mettre à jour le deuxième commentaire'],
['comment' => 'Créer un nouveau commentaire'],
]
];

Si vous sauvegardez des associations hasMany et voulez lier des enregistrements
existants à un nouveau parent, vous pouvez utiliser le format ``_ids``::

Expand Down

0 comments on commit 3785f8b

Please sign in to comment.