Skip to content

Commit f57e728

Browse files
committed
Move type map documentation to persistable classes tutorial
1 parent 720117f commit f57e728

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

docs/reference/bson.txt

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ By default, the |php-library| returns BSON documents as
2121
:phpclass:`MongoDB\\Model\\BSONDocument` objects and BSON arrays as
2222
:phpclass:`MongoDB\\Model\\BSONArray` objects, respectively.
2323

24-
BSON Classes
25-
------------
24+
Classes
25+
-------
2626

2727
.. phpclass:: MongoDB\\Model\\BSONArray
2828

@@ -49,40 +49,3 @@ BSON Classes
4949
class. During BSON and JSON serialization, instances of this class will
5050
serialize as a document type (:php:`object casting
5151
<types.type-juggling#language.types.typecasting>` is used internally).
52-
53-
.. _php-type-map:
54-
55-
Type Maps
56-
---------
57-
58-
Most methods that read data from MongoDB support a ``typeMap`` option, which
59-
allows control over how BSON is converted to PHP. Additionally,
60-
the :phpclass:`MongoDB\\Client`, :phpclass:`MongoDB\\Database`, and
61-
:phpclass:`MongoDB\\Collection` classes accept a ``typeMap`` option, which can
62-
be used to specify a default type map to apply to any supporting methods and
63-
selected classes (e.g. :phpmethod:`MongoDB\\Client::selectDatabase()`).
64-
65-
The :phpclass:`MongoDB\\Client`, :phpclass:`MongoDB\\Database`, and
66-
:phpclass:`MongoDB\\Collection` classes use the following type map by
67-
default:
68-
69-
.. code-block:: php
70-
71-
[
72-
'array' => 'MongoDB\Model\BSONArray',
73-
'document' => 'MongoDB\Model\BSONDocument',
74-
'root' => 'MongoDB\Model\BSONDocument',
75-
]
76-
77-
The type map above will convert BSON documents and arrays to
78-
:phpclass:`MongoDB\\Model\\BSONDocument` and
79-
:phpclass:`MongoDB\\Model\\BSONArray` objects, respectively. The ``root`` and
80-
``document`` keys are used to distinguish the top-level BSON document from
81-
embedded documents, respectively.
82-
83-
A type map may specify any class that implements
84-
:php:`MongoDB\\BSON\\Unserializable <mongodb-bson-unserializable>` as well as
85-
``"array"``, ``"stdClass``", and ``"object"`` (``"stdClass``" and ``"object"``
86-
are aliases of one another).
87-
88-
.. seealso:: :php:`Deserialization from BSON <manual/en/mongodb.persistence.deserialization.php>` in the PHP manual

docs/tutorial/persistable-classes.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,39 @@ The same document in the MongoDB shell might display as:
116116

117117
:php:`MongoDB\\BSON\\Persistable <mongodb-bson-persistable>` may only be used
118118
for root and embedded BSON documents. It may not be used for BSON arrays.
119+
.. _php-type-map:
120+
121+
Type Maps
122+
---------
123+
124+
Most methods that read data from MongoDB support a ``typeMap`` option, which
125+
allows control over how BSON is converted to PHP. Additionally,
126+
the :phpclass:`MongoDB\\Client`, :phpclass:`MongoDB\\Database`, and
127+
:phpclass:`MongoDB\\Collection` classes accept a ``typeMap`` option, which can
128+
be used to specify a default type map to apply to any supporting methods and
129+
selected classes (e.g. :phpmethod:`MongoDB\\Client::selectDatabase()`).
130+
131+
The :phpclass:`MongoDB\\Client`, :phpclass:`MongoDB\\Database`, and
132+
:phpclass:`MongoDB\\Collection` classes use the following type map by
133+
default:
134+
135+
.. code-block:: php
136+
137+
[
138+
'array' => 'MongoDB\Model\BSONArray',
139+
'document' => 'MongoDB\Model\BSONDocument',
140+
'root' => 'MongoDB\Model\BSONDocument',
141+
]
142+
143+
The type map above will convert BSON documents and arrays to
144+
:phpclass:`MongoDB\\Model\\BSONDocument` and
145+
:phpclass:`MongoDB\\Model\\BSONArray` objects, respectively. The ``root`` and
146+
``document`` keys are used to distinguish the top-level BSON document from
147+
embedded documents, respectively.
148+
149+
A type map may specify any class that implements
150+
:php:`MongoDB\\BSON\\Unserializable <mongodb-bson-unserializable>` as well as
151+
``"array"``, ``"stdClass``", and ``"object"`` (``"stdClass``" and ``"object"``
152+
are aliases of one another).
153+
154+
.. seealso:: :php:`Deserialization from BSON <manual/en/mongodb.persistence.deserialization.php>` in the PHP manual

0 commit comments

Comments
 (0)