Cake\ElasticSearch\Marshaller::one PHP Метод

one() публичный Метод

### Options: * fieldList: A whitelist of fields to be assigned to the entity. If not present, the accessible fields list in the entity will be used. * accessibleFields: A list of fields to allow or deny in entity accessible fields. * associated: A list of embedded documents you want to marshal.
public one ( array $data, array $options = [] ) : Cake\ElasticSearch\Document;
$data array The data to hydrate.
$options array List of options
Результат Cake\ElasticSearch\Document;
    public function one(array $data, array $options = [])
    {
        $entityClass = $this->type->entityClass();
        $entity = new $entityClass();
        $entity->source($this->type->name());
        $options += ['associated' => []];
        list($data, $options) = $this->_prepareDataAndOptions($data, $options);
        if (isset($options['accessibleFields'])) {
            foreach ((array) $options['accessibleFields'] as $key => $value) {
                $entity->accessible($key, $value);
            }
        }
        $errors = $this->_validate($data, $options, true);
        $entity->errors($errors);
        foreach (array_keys($errors) as $badKey) {
            unset($data[$badKey]);
        }
        foreach ($this->type->embedded() as $embed) {
            $property = $embed->property();
            if (in_array($embed->alias(), $options['associated']) && isset($data[$property])) {
                $data[$property] = $this->newNested($embed, $data[$property]);
            }
        }
        if (!isset($options['fieldList'])) {
            $entity->set($data);
            return $entity;
        }
        foreach ((array) $options['fieldList'] as $field) {
            if (array_key_exists($field, $data)) {
                $entity->set($field, $data[$field]);
            }
        }
        return $entity;
    }