Extends
lithium\data\Entity
Extends the parent implementation to ensure that child documents are properly synced as well.
Parameters
- mixed $id
- array $data
- array $options Options when calling this method: - `'recursive'` _boolean_: If `true` attempts to sync nested objects as well. Otherwise, only syncs the current object. Defaults to `true`.
Returns
voidSource
public function sync($id = null, array $data = array(), array $options = array()) {
$defaults = array('recursive' => true);
$options += $defaults;
if (!$options['recursive']) {
return parent::sync($id, $data, $options);
}
foreach ($this->_updated as $key => $val) {
if (is_object($val) && method_exists($val, 'sync')) {
$nested = isset($data[$key]) ? $data[$key] : array();
$this->_updated[$key]->sync(null, $nested, $options);
}
}
parent::sync($id, $data, $options);
}