浏览代码

adds more docs

Johannes M. Schmitt 12 年之前
父节点
当前提交
9a50b158fa
共有 2 个文件被更改,包括 19 次插入3 次删除
  1. 15 1
      UPGRADING.md
  2. 4 2
      src/JMS/Serializer/SerializerInterface.php

+ 15 - 1
UPGRADING.md

@@ -2,4 +2,18 @@ From 0.11 to 0.12
 =================
 
 - GraphNavigator::detachObject has been removed, you can directly use Context::stopVisiting instead.
-- VisitorInterface::getNavigator was deprecated, instead use Context::accept
+- VisitorInterface::getNavigator was deprecated, instead use Context::accept
+- Serializer::setGroups, Serializer::setExclusionStrategy and Serializer::setVersion were removed, these settings must
+  now be passed as part of a new Context object.
+
+    Before:
+
+        $serializer->setVersion(1);
+        $serializer->serialize($data, 'json');
+
+    After:
+
+        $serializer->serialize($data, 'json', Context::create()->setVersion(1));
+
+- All visit??? methods of the VisitorInterface, now require a third argument, the Context; the context is for example
+  passed as an additional argument to handler, exclusion strategies, and also available in event listeners.

+ 4 - 2
src/JMS/Serializer/SerializerInterface.php

@@ -30,10 +30,11 @@ interface SerializerInterface
      *
      * @param object|array|scalar $data
      * @param string $format
+     * @param Context $context
      *
      * @return string
      */
-    public function serialize($data, $format);
+    public function serialize($data, $format, Context $context = null);
 
     /**
      * Deserializes the given data to the specified type.
@@ -41,8 +42,9 @@ interface SerializerInterface
      * @param string $data
      * @param string $type
      * @param string $format
+     * @param Context $context
      *
      * @return object|array|scalar
      */
-    public function deserialize($data, $type, $format);
+    public function deserialize($data, $type, $format, Context $context = null);
 }