Quellcode durchsuchen

Allow setting a document in MongoWriteConcernException

Andreas Braun vor 9 Jahren
Ursprung
Commit
bcd9792416
1 geänderte Dateien mit 25 neuen und 2 gelöschten Zeilen
  1. 25 2
      lib/Mongo/MongoWriteConcernException.php

+ 25 - 2
lib/Mongo/MongoWriteConcernException.php

@@ -21,11 +21,34 @@ if (class_exists('MongoWriteConcernException', false)) {
  * <p>(PECL mongo &gt;= 1.5.0)</p>
  * @link http://php.net/manual/en/class.mongowriteconcernexception.php#class.mongowriteconcernexception
  */
-class MongoWriteConcernException extends MongoCursorException {
+class MongoWriteConcernException extends MongoCursorException
+{
+    private $document;
+
+    /**
+     * MongoWriteConcernException constructor.
+     *
+     * @param string $message
+     * @param int $code
+     * @param Exception|null $previous
+     * @param null $document
+     *
+     * @internal The $document parameter is not part of the ext-mongo API
+     */
+    public function __construct($message = '', $code = 0, Exception $previous = null, $document = null)
+    {
+        parent::__construct($message, $code, $previous);
+
+        $this->document = $document;
+    }
+
     /**
      * Get the error document
      * @link http://php.net/manual/en/mongowriteconcernexception.getdocument.php
      * @return array <p>A MongoDB document, if available, as an array.</p>
      */
-    public function getDocument() {}
+    public function getDocument()
+    {
+        return $this->document;
+    }
 }