Skip to content

Commit 3d742a3

Browse files
authored
Merge pull request #8324 from kenjis/docs-model-event
docs: improve Model Event
2 parents 2420424 + 97c4518 commit 3d742a3

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

user_guide_src/source/models/model.rst

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,19 @@ points in the model's execution can be affected, each through a class property:
738738
Defining Callbacks
739739
==================
740740

741-
You specify the callbacks by first creating a new class method in your model to use. This class will always
742-
receive a ``$data`` array as its only parameter. The exact contents of the ``$data`` array will vary between events, but
743-
will always contain a key named **data** that contains the primary data passed to the original method. In the case
744-
of the insert* or update* methods, that will be the key/value pairs that are being inserted into the database. The
745-
main array will also contain the other values passed to the method, and be detailed later. The callback method
746-
must return the original $data array so other callbacks have the full information.
741+
You specify the callbacks by first creating a new class method in your model to use.
742+
743+
This class method will always receive a ``$data`` array as its only parameter.
744+
745+
The exact contents of the ``$data`` array will vary between events, but will always
746+
contain a key named ``data`` that contains the primary data passed to the original
747+
method. In the case of the **insert*()** or **update*()** methods, that will be
748+
the key/value pairs that are being inserted into the database. The main ``$data``
749+
array will also contain the other values passed to the method, and be detailed
750+
in `Event Parameters`_.
751+
752+
The callback method must return the original ``$data`` array so other callbacks
753+
have the full information.
747754

748755
.. literalinclude:: model/050.php
749756

@@ -774,37 +781,36 @@ passed to each event:
774781
Event $data contents
775782
================= =========================================================================================================
776783
beforeInsert **data** = the key/value pairs that are being inserted. If an object or Entity class is passed to the
777-
insert method, it is first converted to an array.
784+
``insert()`` method, it is first converted to an array.
778785
afterInsert **id** = the primary key of the new row, or 0 on failure.
779786
**data** = the key/value pairs being inserted.
780-
**result** = the results of the insert() method used through the Query Builder.
787+
**result** = the results of the ``insert()`` method used through the Query Builder.
781788
beforeUpdate **id** = the array of primary keys of the rows being updated.
782789
**data** = the key/value pairs that are being updated. If an object or Entity class is passed to the
783-
update method, it is first converted to an array.
790+
``update()`` method, it is first converted to an array.
784791
afterUpdate **id** = the array of primary keys of the rows being updated.
785792
**data** = the key/value pairs being updated.
786-
**result** = the results of the update() method used through the Query Builder.
793+
**result** = the results of the ``update()`` method used through the Query Builder.
787794
beforeFind The name of the calling **method**, whether a **singleton** was requested, and these additional fields:
788-
- first() No additional fields
789-
- find() **id** = the primary key of the row being searched for.
790-
- findAll() **limit** = the number of rows to find.
795+
- ``first()`` No additional fields
796+
- ``find()`` **id** = the primary key of the row being searched for.
797+
- ``findAll()`` **limit** = the number of rows to find.
791798
**offset** = the number of rows to skip during the search.
792799
afterFind Same as **beforeFind** but including the resulting row(s) of data, or null if no result found.
793-
beforeDelete Varies by delete* method. See the following:
794-
- delete() **id** = primary key of row being deleted.
800+
beforeDelete **id** = primary key of row being passed to the ``delete()`` method.
795801
**purge** = boolean whether soft-delete rows should be hard deleted.
796-
afterDelete **id** = primary key of row being deleted.
802+
afterDelete **id** = primary key of row being passed to the ``delete()`` method.
797803
**purge** = boolean whether soft-delete rows should be hard deleted.
798-
**result** = the result of the delete() call on the Query Builder.
804+
**result** = the result of the ``delete()`` call on the Query Builder.
799805
**data** = unused.
800806
beforeInsertBatch **data** = associative array of values that are being inserted. If an object or Entity class is passed to the
801-
insertBatch method, it is first converted to an array.
807+
``insertBatch()`` method, it is first converted to an array.
802808
afterInsertBatch **data** = the associative array of values being inserted.
803-
**result** = the results of the insertbatch() method used through the Query Builder.
809+
**result** = the results of the ``insertbatch()`` method used through the Query Builder.
804810
beforeUpdateBatch **data** = associative array of values that are being updated. If an object or Entity class is passed to the
805-
updateBatch method, it is first converted to an array.
811+
``updateBatch()`` method, it is first converted to an array.
806812
afterUpdateBatch **data** = the key/value pairs being updated.
807-
**result** = the results of the updateBatch() method used through the Query Builder.
813+
**result** = the results of the ``updateBatch()`` method used through the Query Builder.
808814
================= =========================================================================================================
809815

810816
Modifying Find* Data

0 commit comments

Comments
 (0)