function writeObjectAndAddToState(oFlexObject, oStoredResponse, sParentVersion) {
			// new public variant should not be visible for other users
			if (oFlexObject.getLayer() === Layer.PUBLIC) {
				oFlexObject.setFavorite(false);
			}
			// TODO: remove this line as soon as layering and a condensing is in place
			return Storage.write({
				flexObjects: [oFlexObject.convertToFileContent()],
				layer: oFlexObject.getLayer(),
				transport: oFlexObject.getRequest(),
				isLegacyVariant: oFlexObject.isVariant && oFlexObject.isVariant(),
				parentVersion: sParentVersion
			}).then(function(result) {
				// updateFlexObject and versionModel
				if (result && result.response && result.response[0]) {
					oFlexObject.setResponse(result.response[0]);
					if (sParentVersion) {
						Versions.onAllChangesSaved({
							reference: result.response[0].reference,
							layer: result.response[0].layer,
							draftFilenames: [result.response[0].fileName]
						});
					}
				} else {
					oFlexObject.setState(States.LifecycleState.PERSISTED);
				}
			}).then(function() {
				// update StorageResponse
				const oFileContent = oFlexObject.convertToFileContent();
				getSubSection(oStoredResponse.changes.comp, oFlexObject).push(oFileContent);
				FlexState.getFlexObjectsDataSelector().checkUpdate({ reference: mPropertyBag.reference });
				return oFileContent;
			});
		}
Saves/flushes all current changes and variants of a smart variant.

@param {object} mPropertyBag - Map of parameters, see below
@param {string} mPropertyBag.reference - Flex reference of the app
@param {string} mPropertyBag.persistencyKey - Key of the variant management

@returns {Promise} Promise resolving with an array of responses or rejecting with the first error
@private