Skip to content

Commit

Permalink
docs: add user guide
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Feb 20, 2023
1 parent 2c815c6 commit 6f52f1e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions user_guide_src/source/changelogs/v4.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Others
Model
=====

- Added special getter/setter to Entity to avoid method name conflicts.
See :ref:`entities-special-getter-setter`.

Libraries
=========

Expand Down
19 changes: 19 additions & 0 deletions user_guide_src/source/models/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
============

Expand Down

0 comments on commit 6f52f1e

Please sign in to comment.