Skip to content

Commit 8006f5f

Browse files
committed
docs: add user guide
1 parent 2c815c6 commit 8006f5f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

user_guide_src/source/changelogs/v4.4.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ Others
6262
Model
6363
=====
6464

65+
- Added special getter/setter to Entity to avoid method name conflicts.
66+
See :ref:`entities-special-getter-setter`.
67+
6568
Libraries
6669
=========
6770

user_guide_src/source/models/entities.rst

+19
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,25 @@ business logic and create objects that are pleasant to use.
131131

132132
.. literalinclude:: entities/007.php
133133

134+
.. _entities-special-getter-setter:
135+
136+
Special Getter/Setter
137+
---------------------
138+
139+
.. versionadded:: 4.4.0
140+
141+
For example, if your Entity's parent class already has a ``getParent()`` method
142+
defined, and your Entity also has a column named ``parent``, when you try to add
143+
business logic to the ``getParent()`` method in your Entity class, the method is
144+
already defined.
145+
146+
In such a case, you can use the special getter/setter. Instead of ``getX()``/``setX()``,
147+
set ``_getX()``/``_setX()``.
148+
149+
In the above example, if your Entity has the ``_getParent()`` method, the method
150+
will be used when you get ``$entity->parent``, and the ``_setParent()`` method
151+
will be used when you set `$entity->parent``.
152+
134153
Data Mapping
135154
============
136155

0 commit comments

Comments
 (0)