浏览代码

added example of virtualproperty with changing order

Jaap van Otterdijk 12 年之前
父节点
当前提交
a23d9cfe66
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22 0
      doc/reference/annotations.rst

+ 22 - 0
doc/reference/annotations.rst

@@ -147,6 +147,28 @@ default the order is undefined, but you may change it to either "alphabetical",
         private $name;
     }
 
+    /**
+     * @AccessorOrder("custom", custom = {"name", "SomeMethod" ,"id"})
+     *
+     * Resulting Property Order: name, mood, id
+     */
+    class User
+    {
+        private $id;
+        private $name;
+
+        /**
+         * @Serializer\VirtualProperty
+         * @Serializer\SerializedName("mood")
+         *
+         * @return string
+         */
+        public function getSomeMethod()
+        {
+            return 'happy';
+        }
+    }
+
 @VirtualProperty
 ~~~~~~~~~~~~~~~~
 This annotation can be defined on a method to indicate that the data returned by