protected static function _append($changes, $key, $value, $change)
{
$options = array('finalize' => false);
if (!is_object($value) || !method_exists($value, 'export')) {
$changes[$change][$key] = $change === 'update' ? $value : true;
return $changes;
}
if (!$value->exists()) {
$changes[$change][$key] = static::_create($value->export(), $options);
return $changes;
}
if ($change === 'update') {
$export = compact('key') + $value->export();
return Set::merge($changes, static::_update($export));
}
if ($children = static::_update($value->export())) {
return Set::merge($changes, $children);
}
$changes[$change][$key] = true;
return $changes;
}