Browse Source

added some doc for lifecycle callbacks

Johannes Schmitt 14 năm trước cách đây
mục cha
commit
c3ba6237c1
1 tập tin đã thay đổi với 16 bổ sung0 xóa
  1. 16 0
      Resources/doc/index.rst

+ 16 - 0
Resources/doc/index.rst

@@ -145,6 +145,12 @@ There are several ways how you can customize the serialization process:
 2. Implementing NormalizableInterface
 2. Implementing NormalizableInterface
 3. Adding a Custom Normalizer
 3. Adding a Custom Normalizer
 
 
+Lifecycle Callbacks
+~~~~~~~~~~~~~~~~~~~
+If you need to perform some clean-up of the object during serialization/deserialization,
+you may take advantage of two built-in lifecycle callbacks, see @PreSerialize and @PostDeserialize
+below.
+
 Wiring Custom Normalizers/Encoders
 Wiring Custom Normalizers/Encoders
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
@@ -212,6 +218,16 @@ property was available. If a later version is serialized, then this property is
 excluded automatically. The version must be in a format that is understood by 
 excluded automatically. The version must be in a format that is understood by 
 PHP's ``version_compare`` function.
 PHP's ``version_compare`` function.
 
 
+@PreSerialize
+~~~~~~~~~~~~~
+This annotation can be defined on a method which is supposed to be called before
+the serialization of the object starts.
+
+@PostDeserialize
+~~~~~~~~~~~~~~~~
+This annotation can be defined on a method which is supposed to be called after
+the object has been deserialized.
+
 @Type
 @Type
 ~~~~~
 ~~~~~
 This annotation can be defined on a property to specify the type of that property.
 This annotation can be defined on a property to specify the type of that property.