Cake\ElasticSearch\Type::get PHP Method

get() public method

public get ( string $primaryKey, array $options = [] ) : Document
$primaryKey string The document's primary key
$options array An array of options
return Document A new Elasticsearch document entity
    public function get($primaryKey, $options = [])
    {
        $type = $this->connection()->getIndex()->getType($this->name());
        $result = $type->getDocument($primaryKey, $options);
        $class = $this->entityClass();
        $options = ['markNew' => false, 'markClean' => true, 'useSetters' => false, 'source' => $this->name()];
        $data = $result->getData();
        $data['id'] = $result->getId();
        foreach ($this->embedded() as $embed) {
            $prop = $embed->property();
            if (isset($data[$prop])) {
                $data[$prop] = $embed->hydrate($data[$prop], $options);
            }
        }
        return new $class($data, $options);
    }