lithium\data\source\http\adapter\CouchDb::item()
Returns a newly-created Document object, bound to a model and populated with default data
and options.
Parameters
-
string
$modelA fully-namespaced class name representing the model class to which the
Documentobject will be bound. -
array
$dataThe default data with which the new
Documentshould be populated. -
array
$optionsAny additional options to pass to the
Document's constructor
Returns
objectReturns a new, un-saved Document object bound to the model class specified
in $model.
Source
public function item($model, array $data = [], array $options = []) {
$defaults = ['class' => 'entity'];
$options += $defaults;
if ($options['class'] === 'entity') {
return $model::create($this->_format($data), $options);
}
foreach ($data as $key => $value) {
if (isset($value['doc'])) {
$value = $value['doc'];
}
if (isset($value['value'])) {
$value = $value['value'];
}
$data[$key] = $this->_format($value);
}
return $model::create($data, $options);
}