Johannes M. Schmitt преди 13 години
родител
ревизия
d3d0852e11
променени са 3 файла, в които са добавени 54 реда и са изтрити 19 реда
  1. 17 4
      Resources/doc/cookbook/custom_handlers.rst
  2. 5 3
      Resources/doc/cookbook/versioning_objects.rst
  3. 32 12
      Resources/doc/reference/annotations.rst

+ 17 - 4
Resources/doc/cookbook/custom_handlers.rst

@@ -1,5 +1,8 @@
 Custom De-/Serialization Handlers
----------------------------------
+=================================
+
+Introduction
+------------
 This allows you to change the way of how a specifc type is being de-/serialized.
 
 Any handler must implement either the ``SerializationHandlerInterface``, or
@@ -10,18 +13,26 @@ can use as a starting point.
 Custom handlers are normal services, and thus can have dependencies on any
 other service available in the dependency injection container.
 
+Configuration
+-------------
 After you have written your handler, you can write a service definition. Such
-as the following::
+as the following:
+
+.. code-block :: xml
 
     <service id="acme_foo.serializer.my_handler"
              class="Acme\FooBundle\Serializer\MyHandler"
              public="false"
              />
              
+The Handler Factory
+-------------------
 What is left to do is to publish our new handler to this bundle. So it gets
 picked up, and wired correctly. In order to do this, this bundle uses a 
 configuration system similar to that of the SecurityBundle. Each handler needs 
-a corresponding definition factory::
+a corresponding definition factory:
+
+.. code-block :: php
 
     <?php
     
@@ -62,7 +73,9 @@ in the ``addConfiguration`` method, and then process that configuration in the
 ``getHandlerId`` method. 
 
 The last thing left to do, is to add this factory to this bundle. This is
-done by adding a ``configureSerializerExtension`` to your bundle class::
+done by adding a ``configureSerializerExtension`` to your bundle class:
+
+.. code-block :: php
 
     <?php
     

+ 5 - 3
Resources/doc/cookbook/versioning_objects.rst

@@ -4,7 +4,7 @@ JMSSerializerBundle comes by default with a very neat feature which allows
 you to add versioning support to your objects, e.g. if you want to
 expose them via an API that is consumed by a third-party:
 
-::
+.. code-block :: php
 
     <?php
 
@@ -27,9 +27,11 @@ expose them via an API that is consumed by a third-party:
     ``@Until``, and ``@Since`` both accept a standardized PHP version number.
 
 If you have annotated your objects like above, you can serializing different
-versions like this::
+versions like this:
+
+.. code-block :: php
 
     <?php
 
     $serializer->setVersion('1.0');
-    $serializer->serialize(new VersionObject(), 'json');
+    $serializer->serialize(new VersionObject(), 'json');

+ 32 - 12
Resources/doc/reference/annotations.rst

@@ -50,7 +50,11 @@ PHP's ``version_compare`` function.
 ~~~~~~~~~~~
 This annotation can be defined on a property, or a class to specify in which way
 the properties should be accessed. By default, the serializer will retrieve, or
-set the value via reflection, but you may change this to use a public method instead::
+set the value via reflection, but you may change this to use a public method instead:
+
+.. code-block :: php
+
+    <?php
 
     /** @AccessType("public_method") */
     class User
@@ -71,7 +75,11 @@ set the value via reflection, but you may change this to use a public method ins
 @Accessor
 ~~~~~~~~~
 This annotation can be defined on a property to specify which public method should
-be called to retrieve, or set the value of the given property::
+be called to retrieve, or set the value of the given property:
+
+.. code-block :: php
+
+    <?php
 
     class User
     {
@@ -98,7 +106,9 @@ This annotation can be defined on a class to control the order of properties. By
 default the order is undefined, but you may change it to either "alphabetical", or
 "custom".
 
-::
+.. code-block :: php
+    
+    <?php
 
     /** 
      * @AccessorOrder("alphabetical") 
@@ -191,7 +201,9 @@ Available Types:
 |                           | into Doctrine's ArrayCollection class.           |
 +---------------------------+--------------------------------------------------+
 
-Examples::
+Examples:
+
+.. code-block :: php
 
     <?php
 
@@ -236,7 +248,7 @@ Examples::
 ~~~~~~~~
 This allows you to specify the name of the top-level element.
 
-::
+.. code-block :: php
 
     <?php
 
@@ -248,7 +260,9 @@ This allows you to specify the name of the top-level element.
         private $name = 'Johannes';
     }
 
-Resulting XML::
+Resulting XML:
+
+.. code-block :: xml
 
     <user>
         <name><![CDATA[Johannes]]></name>
@@ -259,7 +273,7 @@ Resulting XML::
 This allows you to mark properties which should be set as attributes,
 and not as child elements.
 
-::
+.. code-block :: php
 
     <?php
 
@@ -272,7 +286,9 @@ and not as child elements.
         private $name = 'Johannes';
     }
 
-Resulting XML::
+Resulting XML:
+
+.. code-block :: xml
 
     <result id="1">
         <name><![CDATA[Johannes]]></name>
@@ -284,7 +300,7 @@ This allows you to mark properties which should be set as the value of the
 current element. Note that this has the limitation that any additional 
 properties of that object must have the @XmlAttribute annotation.
 
-::
+.. code-block :: php
 
     <?php
     
@@ -302,7 +318,9 @@ properties of that object must have the @XmlAttribute annotation.
         private $amount = 1.23;
     }
     
-Resulting XML::
+Resulting XML:
+
+.. code-block :: xml
 
     <price currency="EUR">1.23</price>
 
@@ -312,7 +330,7 @@ This allows you to define several properties of how arrays should be
 serialized. This is very similar to @XmlMap, and should be used if the
 keys of the array are not important.
 
-::
+.. code-block :: php
 
     <?php
 
@@ -341,7 +359,9 @@ keys of the array are not important.
         }
     }
 
-Resulting XML::
+Resulting XML:
+
+.. code-block :: xml
 
     <post>
         <comment>