浏览代码

updates docs

Johannes M. Schmitt 12 年之前
父节点
当前提交
2fcf606aeb
共有 1 个文件被更改,包括 6 次插入14 次删除
  1. 6 14
      doc/cookbook/exclusion_strategies.rst

+ 6 - 14
doc/cookbook/exclusion_strategies.rst

@@ -73,14 +73,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
+    use JMS\Serializer\SerializationContext;
 
-    $serializer->setVersion('1.0');
-    $serializer->serialize(new VersionObject(), 'json');
+    $serializer->serialize(new VersionObject(), 'json', SerializationContext::create()->setVersion(1));
 
 
 Creating Different Views of Your Objects
@@ -93,8 +90,6 @@ You can achieve that by using the ``@Groups`` annotation on your properties.
 
 .. code-block :: php
 
-    <?php
-
     use JMS\Serializer\Annotation\Groups;
 
     class BlogPost
@@ -112,11 +107,8 @@ You can achieve that by using the ``@Groups`` annotation on your properties.
         private $comments;
     }
 
-You can then tell the serializer which groups to serialize in your controller:
-
-.. code-block :: php
+You can then tell the serializer which groups to serialize in your controller::
 
-    <?php
+    use JMS\Serializer\SerializationContext;
 
-    $serializer->setGroups(array('list'));
-    $serializer->serialize(new BlogPost(), 'json');
+    $serializer->serialize(new BlogPost(), 'json', SerializationContext::create()->setGroups(array('list')));