Cake\ElasticSearch\Type::newEntity PHP Method

newEntity() public method

This is most useful when hydrating request data back into entities. For example, in your controller code: $article = $this->Articles->newEntity($this->request->data()); The hydrated entity will correctly do an insert/update based on the primary key data existing in the database when the entity is saved. Until the entity is saved, it will be a detached record.
public newEntity ( array | null $data = null, array $options = [] ) : Cake\Datasource\EntityInterface
$data array | null The data to build an entity with.
$options array A list of options for the object hydration.
return Cake\Datasource\EntityInterface
    public function newEntity($data = null, array $options = [])
    {
        if ($data === null) {
            $class = $this->entityClass();
            return new $class([], ['source' => $this->name()]);
        }
        return $this->marshaller()->one($data, $options);
    }