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
$model
A fully-namespaced class name representing the model class to which the
Document
object will be bound. -
array
$data
The default data with which the new
Document
should be populated. -
array
$options
Any 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);
}