lithium\data\entity\Document::sync()

public method

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

void

Source

	public function sync($id = null, array $data = [], array $options = []) {
		$defaults = ['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] : [];
				$this->_updated[$key]->sync(null, $nested, $options);
			}
		}
		parent::sync($id, $data, $options);
	}