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 ============