Extends
lithium\core\Object
Called after an `Entity` is saved. Updates the object's internal state to reflect the
corresponding database entity, and sets the `Entity` object's key, if this is a newly-created
object. **Do not** call this method if you intend to update the database's copy of the
entity. Instead, see `Model::save()`.
Parameters
- mixed $id The ID to assign, where applicable.
- array $data Any additional generated data assigned to the object by the database.
- array $options Method options: - `'materialize'` _boolean_: Determines whether or not the flag should be set that indicates that this entity exists in the data store. Defaults to `true`.
Returns
voidSource
public function sync($id = null, array $data = array(), array $options = array()) {
$defaults = array('materialize' => true);
$options += $defaults;
$model = $this->_model;
$key = array();
if ($options['materialize']) {
$this->_exists = true;
}
if ($id && $model) {
$key = $model::meta('key');
$key = is_array($key) ? array_combine($key, $id) : array($key => $id);
}
$this->_data = $this->_updated = ($key + $data + $this->_updated);
}