Replaces the user in Kuzzle’s database layer.

@param array $options Optional parameters
@return Document
169434
public function replace(array $options = [])
    {
        $data = $this->serialize();

        $this->security->getKuzzle()->query(
            $this->security->buildQueryArgs('replaceUser'),
            $data,
            $options
        );

        return $this;
    }
520528
public function setOptions(array $options)
    {
        foreach ($options as $k => $v) {
            $this->_options[$k] = $v;
        }
        return $this;
    }
894169
public function save(array $options = [])
    {
        $data = $this->serialize();

        $this->security->getKuzzle()->query(
            $this->security->buildQueryArgs($this->saveActionName),
            $data,
            $options
        );

        return $this;
    }
1218663
public function findOneAndDelete(array $filter, array $options = [])
    {
        $options['typeMap'] = [
            'root' => $this->documentManager->getProxyClass($this->documentClass),
            'document' => 'array',
        ];

        $document = $this->getCollection()->findOneAndDelete($filter, $options);
        if ($document instanceof DocumentManagerAwareInterface) {
            $document->setManager($this->documentManager);
        }

        return $document;
    }
585793
public function setOptions(array $options)
    {
        if ($this->options && is_array($options)) {
            $options = ArrayUtils::merge($this->options, $options);
        }

        $this->options = $options;

        return $this;
    }
1153061
protected function doInsert(array &$a, array $options)
    {
        $document = $a;
        $options = isset($options['safe']) ? $this->convertWriteConcern($options) : $options;
        $options = isset($options['wtimeout']) ? $this->convertWriteTimeout($options) : $options;
        $options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
        $result = $this->mongoCollection->insert($document, $options);
        if (isset($document['_id'])) {
            $a['_id'] = $document['_id'];
        }
        return $result;
    }
1367151
public function decode(array $options = [])
    {
        $json = json_decode($this->getContents(), true);

        if ($json === null && json_last_error() === JSON_ERROR_NONE) {
            $this->validateSyntax();

            return $this;
        }

        $this->validateSchema();

        return $json;
    }
653361
public function getColumnObject($options)
    {
        $class = $this->getColumnClassName($options);

        return new $class($this->validator, $this->config, $this->db, $options);
    }
553818
public function getFieldObject($options)
    {
        $class = $this->getFieldTypeClass($options['type']);

        return new $class($this->validator, $this->config, $this->db, $options);
    }
360852
public function delete(array $options = [])
    {
        if (!$this->id) {
            throw new InvalidArgumentException('Kuzzle\Document::delete: cannot delete a document without a document ID');
        }

        $this->collection->getKuzzle()->query(
            $this->collection->buildQueryArgs('document', 'delete'),
            $this->collection->getKuzzle()->addHeaders($this->serialize(), $this->headers),
            $options
        );

        return $this->id;
    }
446404
public function withOptions($options)
    {
        if (is_array($options)) {
            $options = new RequestOptions($options);
        }

        $this->options = $options;

        return $this;
    }
138170
public function update(array $options = array())
    {
        $module = $this->utils()->whichModule($this);
        return $this->utils()->update($module, $options);
    }
490784
public function setOptions(array $options)
    {
        $this->validateOptions($options, $this->type);

        $this->options = $options;

        return $this;
    }
1356180
public function addOptions(array $options) : Select
    {
        foreach ($options as $value => $content) {
            $this->addOption($content, $value);
        }

        return $this;
    }
751634
protected function convertWriteConcern(array $options)
    {
        if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
            return $options;
        }

        if (isset($options['safe']) && ! isset($options['w'])) {
            $options['w'] = is_bool($options['safe']) ? (integer) $options['safe'] : $options['safe'];
            unset($options['safe']);
        }

        return $options;
    }
924814
public function create(array $options)
    {
        $entityClass = $this->getClassName($options['entity-table']);
        $closureClass = $this->getClassName($options['closure-table']);
        $useInnoDB = $options['use-innodb'];
        $stubPrefix = $useInnoDB ? '-innodb' : '';

        $path = $this->getPath($options['entity-table'], $options['migrations-path']);
        $stub = $this->getStub('migration' . $stubPrefix, 'migrations');

        $this->filesystem->put(
            $path,
            $this->parseStub($stub, [
            'entity_table' => $options['entity-table'],
            'entity_class' => $entityClass,
            'closure_table' => $options['closure-table'],
            'closure_class' => $closureClass,
            ])
        );

        return [$path];
    }
983221
public function fetchUser($id, array $options = [])
    {
        $data = [
            '_id' => $id
        ];

        $response = $this->kuzzle->query(
            $this->buildQueryArgs('getUser'),
            $data,
            $options
        );

        return new User($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']);
    }