|
|
@@ -20,7 +20,7 @@ if (class_exists('MongoId', false)) {
|
|
|
use Alcaeus\MongoDbAdapter\TypeInterface;
|
|
|
use MongoDB\BSON\ObjectID;
|
|
|
|
|
|
-class MongoId implements Serializable, TypeInterface
|
|
|
+class MongoId implements Serializable, TypeInterface, JsonSerializable
|
|
|
{
|
|
|
/*
|
|
|
* @var ObjectID
|
|
|
@@ -201,6 +201,16 @@ class MongoId implements Serializable, TypeInterface
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @return stdClass
|
|
|
+ */
|
|
|
+ public function jsonSerialize()
|
|
|
+ {
|
|
|
+ $object = new stdClass();
|
|
|
+ $object->{'$id'} = (string) $this->objectID;
|
|
|
+ return $object;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* @param $id
|
|
|
* @throws MongoException
|
|
|
*/
|