芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/atvcmsTRASH.com.br/maisqtv2/vendor/mongodb/mongodb/src/Operation/FindAndModify.php
false, 'remove' => false, 'upsert' => false, ]; if (isset($options['arrayFilters']) && ! is_array($options['arrayFilters'])) { throw InvalidArgumentException::invalidType('"arrayFilters" option', $options['arrayFilters'], 'array'); } if (isset($options['bypassDocumentValidation']) && ! is_bool($options['bypassDocumentValidation'])) { throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean'); } if (isset($options['collation']) && ! is_array($options['collation']) && ! is_object($options['collation'])) { throw InvalidArgumentException::invalidType('"collation" option', $options['collation'], 'array or object'); } if (isset($options['fields']) && ! is_array($options['fields']) && ! is_object($options['fields'])) { throw InvalidArgumentException::invalidType('"fields" option', $options['fields'], 'array or object'); } if (isset($options['maxTimeMS']) && ! is_integer($options['maxTimeMS'])) { throw InvalidArgumentException::invalidType('"maxTimeMS" option', $options['maxTimeMS'], 'integer'); } if ( ! is_bool($options['new'])) { throw InvalidArgumentException::invalidType('"new" option', $options['new'], 'boolean'); } if (isset($options['query']) && ! is_array($options['query']) && ! is_object($options['query'])) { throw InvalidArgumentException::invalidType('"query" option', $options['query'], 'array or object'); } if ( ! is_bool($options['remove'])) { throw InvalidArgumentException::invalidType('"remove" option', $options['remove'], 'boolean'); } if (isset($options['session']) && ! $options['session'] instanceof Session) { throw InvalidArgumentException::invalidType('"session" option', $options['session'], 'MongoDB\Driver\Session'); } if (isset($options['sort']) && ! is_array($options['sort']) && ! is_object($options['sort'])) { throw InvalidArgumentException::invalidType('"sort" option', $options['sort'], 'array or object'); } if (isset($options['typeMap']) && ! is_array($options['typeMap'])) { throw InvalidArgumentException::invalidType('"typeMap" option', $options['typeMap'], 'array'); } if (isset($options['update']) && ! is_array($options['update']) && ! is_object($options['update'])) { throw InvalidArgumentException::invalidType('"update" option', $options['update'], 'array or object'); } if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) { throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern'); } if ( ! is_bool($options['upsert'])) { throw InvalidArgumentException::invalidType('"upsert" option', $options['upsert'], 'boolean'); } if ( ! (isset($options['update']) xor $options['remove'])) { throw new InvalidArgumentException('The "remove" option must be true or an "update" document must be specified, but not both'); } if (isset($options['writeConcern']) && $options['writeConcern']->isDefault()) { unset($options['writeConcern']); } $this->databaseName = (string) $databaseName; $this->collectionName = (string) $collectionName; $this->options = $options; } /** * Execute the operation. * * @see Executable::execute() * @param Server $server * @return array|object|null * @throws UnexpectedValueException if the command response was malformed * @throws UnsupportedException if array filters, collation, or write concern is used and unsupported * @throws DriverRuntimeException for other driver errors (e.g. connection errors) */ public function execute(Server $server) { if (isset($this->options['arrayFilters']) && ! \MongoDB\server_supports_feature($server, self::$wireVersionForArrayFilters)) { throw UnsupportedException::arrayFiltersNotSupported(); } if (isset($this->options['collation']) && ! \MongoDB\server_supports_feature($server, self::$wireVersionForCollation)) { throw UnsupportedException::collationNotSupported(); } if (isset($this->options['writeConcern']) && ! \MongoDB\server_supports_feature($server, self::$wireVersionForWriteConcern)) { throw UnsupportedException::writeConcernNotSupported(); } $cursor = $server->executeWriteCommand($this->databaseName, new Command($this->createCommandDocument($server)), $this->createOptions()); $result = current($cursor->toArray()); if ( ! isset($result->value)) { return null; } if ( ! is_object($result->value)) { throw new UnexpectedValueException('findAndModify command did not return a "value" document'); } if (isset($this->options['typeMap'])) { return \MongoDB\apply_type_map_to_document($result->value, $this->options['typeMap']); } return $result->value; } public function getCommandDocument(Server $server) { return $this->createCommandDocument($server); } /** * Create the findAndModify command document. * * @return array */ private function createCommandDocument(Server $server) { $cmd = ['findAndModify' => $this->collectionName]; if ($this->options['remove']) { $cmd['remove'] = true; } else { $cmd['new'] = $this->options['new']; $cmd['upsert'] = $this->options['upsert']; } foreach (['collation', 'fields', 'query', 'sort', 'update'] as $option) { if (isset($this->options[$option])) { $cmd[$option] = (object) $this->options[$option]; } } if (isset($this->options['arrayFilters'])) { $cmd['arrayFilters'] = $this->options['arrayFilters']; } if (isset($this->options['maxTimeMS'])) { $cmd['maxTimeMS'] = $this->options['maxTimeMS']; } if (isset($this->options['bypassDocumentValidation']) && \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)) { $cmd['bypassDocumentValidation'] = $this->options['bypassDocumentValidation']; } return $cmd; } /** * Create options for executing the command. * * @see http://php.net/manual/en/mongodb-driver-server.executewritecommand.php * @return array */ private function createOptions() { $options = []; if (isset($this->options['session'])) { $options['session'] = $this->options['session']; } if (isset($this->options['writeConcern'])) { $options['writeConcern'] = $this->options['writeConcern']; } return $options; } }