Set this documents payload

@param \StdClass|array $doc the document object
@return self
496530
public function setDocument($doc)
    {
        $this->clearDocument();
        $doc = json_decode(json_encode($doc)); // ensure we are working with an object

        // set known properties
        if (!empty($doc->version)) {
            $this->version = $doc->version;
        }
        if (!empty($doc->href)) {
            $this->href = $doc->href;
        }
        if (!empty($doc->scope)) {
            $this->scope = $doc->scope;
        }
        if (!empty($doc->attributes)) {
            $this->attributes = $doc->attributes;
        }
        if (!empty($doc->links)) {
            $this->links = $doc->links;
        }
        if (!empty($doc->items)) {
            $this->items = $doc->items;
        }
        if (!empty($doc->errors)) {
            $this->errors = $doc->errors;
        }

        // get/set static links (preserving them between sets)
        foreach (self::$_staticLinkNames as $name) {
            if (empty($this->links->$name)) {
                $this->links->$name = self::$_staticLinks->$name;
            } else {
                self::$_staticLinks->$name = $this->links->$name;
            }
        }
        return $this;
    }
1345012
public function setDocumento($documento)
    {
        $documento = substr(Util::onlyNumbers($documento), -14);
        if (!in_array(strlen($documento), [10, 11, 14, 0])) {
            throw new \Exception('Documento inválido');
        }
        $this->documento = $documento;
    }
505287
public function setTitle($title) {
		if (is_array($title) && empty($title)) {
			$this->title = new \stdClass;
		} else {
			$this->title = $title;
		}

		return $this;
	}
423316
public function setObject($property, $content)
    {
        $property = 'og:' . $property;
        $element = new Element('meta');

        $element->attributes[ 'name' ] = $property;
        $element->attributes[ 'content' ] = (is_array($content) ? implode(', ', $content) : trim($content));

        parent::offsetSet($property, $element);

        return $this;
    }
570359
public function setParent(\Neobazaar\Entity\Document $parent = null)
    {
        $this->parent = $parent;
    
        return $this;
    }
368885
public function insert(array &$doc)
    {
        if (isset($doc['_id'])) {
            $clone = $doc;
            unset($clone['_id']);

            $response = $this->client->request('PUT', "/{$this->name}/{$doc['_id']}", [
                'body'    => JSONEncoder::encode($clone),
                'headers' => ['Content-Type' => 'application/json'],
            ]);
        } else {
            $response = $this->client->request('POST', "/{$this->name}/", [
                'body'    => JSONEncoder::encode($doc),
                'headers' => ['Content-Type' => 'application/json'],
            ]);
        }

        if (201 !== $response->getStatusCode()) {
            throw new Exception('Unable to save document');
        }

        $value = JSONEncoder::decode((string) $response->getBody());

        $doc['_id'] = $value['id'];
        $doc['_rev'] = $value['rev'];
    }
823362
public function setByObject(stdClass $object)
    {
        $vars = get_object_vars($object);

        if (is_array($vars)) {
            foreach ($vars as $property => $value) {
                $this->$property = $value;
            }
        }

        return $this;
    }
282449
protected function docToArray(array $doc)
    {
        $values = [];

        foreach ($doc as $key => $value) {

            if ( ! is_array($value)) {
                $values[$key][] = $value;

                continue;
            }

            $values[$key] = $value;
        }

        return $values;
    }
730726
public function setUpsert($data)
    {
        $document = Document::create($data);
        $this->_upsert = $document;

        return $this;
    }
364394
public function updateDocument(\Document $document)
  {
    $arrSet = $this->buildDocumentDataArray($document, false);
    
    $this->Database->prepare("UPDATE tl_dms_documents %s WHERE id=?")->set($arrSet)->execute($document->id);
    
    return $document;
  }
966256
public function remove(Document $document)
    {
        $this->pool->attach($document, self::STATE_REMOVE);

        return $this;
    }
1245827
public function deleteDocuments(array $docs)
    {
        foreach ($docs as $doc) {
            $doc->setIndex($this->getName());
        }

        return $this->getClient()->deleteDocuments($docs);
    }
705010
public function addDocument($document) {
		if(is_array($document)) {
			$this->addDocumentArray($document);
		} elseif ($document instanceof Document) {
			$this->addDocumentObject($document);
		}
	}
38546
public function setDomDocument(\DOMDocument $document)
    {
        if (isset($this->document) && $this->document !== $document) {
            throw new \Exception('Other DOMDocument already set!');
        }

        $this->document = $document;
    }
127000
public function setDocument(\Gpupo\CommonSchema\ORM\Entity\People\Document $document = null)
    {
        $this->document = $document;

        return $this;
    }
1148332
public function persist($collection, array $document)
    {
        

        if ($collection instanceof Collection) {
            $collectionName = $collection->getName();
        } else {
            $collectionName = $collection;
            $collection = static::factory($collection);
        }
        
        $data = $this->marshall($document);
        $result = false;

        
        if (!isset($document['$id'])) {
            $id = $this->insert($collectionName, $data);
            if ($id) {
                $data['$id'] = $id;
                $result = $data;
            }
        } else {
            $data['id'] = $document['$id'];
            unset($data['$id']);
            $result = $this->update($collectionName, $data);

            if ($result) {
                $result = $data;
            }
        }

        return $this->unmarshall($result);
    }
1132300
public function saveDocument(string $id, Document $document): self
    {
        $this->documents[$id] = $document;
        $this->filesystem->put($this->getDocumentPath($id), $this->format->stringify($document->getArrayCopy()));

        return $this;
    }