From 6f52f1e5169d54adc5887528786ad46b9fccc39b Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 20 Feb 2023 10:49:41 +0900 Subject: [PATCH] docs: add user guide --- user_guide_src/source/changelogs/v4.4.0.rst | 3 +++ user_guide_src/source/models/entities.rst | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/user_guide_src/source/changelogs/v4.4.0.rst b/user_guide_src/source/changelogs/v4.4.0.rst index a4d2afbafec2..48d48d6d8c73 100644 --- a/user_guide_src/source/changelogs/v4.4.0.rst +++ b/user_guide_src/source/changelogs/v4.4.0.rst @@ -62,6 +62,9 @@ Others Model ===== +- Added special getter/setter to Entity to avoid method name conflicts. + See :ref:`entities-special-getter-setter`. + Libraries ========= diff --git a/user_guide_src/source/models/entities.rst b/user_guide_src/source/models/entities.rst index df625dd73833..b93777ea125e 100644 --- a/user_guide_src/source/models/entities.rst +++ b/user_guide_src/source/models/entities.rst @@ -131,6 +131,25 @@ business logic and create objects that are pleasant to use. .. literalinclude:: entities/007.php +.. _entities-special-getter-setter: + +Special Getter/Setter +--------------------- + +.. versionadded:: 4.4.0 + +For example, if your Entity's parent class already has a ``getParent()`` method +defined, and your Entity also has a column named ``parent``, when you try to add +business logic to the ``getParent()`` method in your Entity class, the method is +already defined. + +In such a case, you can use the special getter/setter. Instead of ``getX()``/``setX()``, +set ``_getX()``/``_setX()``. + +In the above example, if your Entity has the ``_getParent()`` method, the method +will be used when you get ``$entity->parent``, and the ``_setParent()`` method +will be used when you set ``$entity->parent``. + Data Mapping ============