createAndConnectController = function(oThis, mSettings) {
		var bAsync = mSettings.async;
		var connectToView = function (oController) {
			oThis.oController = oController;
			oController.oView = oThis;
		};

		if (!DesignTime.isControllerCodeDeactivated()) {
			// only set when used internally
			var oController = mSettings.controller,
				sName = oController && typeof oController.getMetadata === "function" && oController.getMetadata().getName();

			if (!oController) {
				oThis.bControllerIsViewManaged = true;

				// get optional default controller name
				let defaultController = oThis._getControllerModuleName() || oThis._getControllerName();
				if (defaultController) {
					// check for controller replacement
					var Component = sap.ui.require("sap/ui/core/Component");
					if (Component) {
						var sControllerReplacement = Component.getCustomizing(oThis, {
							type: "sap.ui.controllerReplacements",
							name: defaultController
						});
						if (sControllerReplacement) {
							defaultController = typeof sControllerReplacement === "string" ? sControllerReplacement : sControllerReplacement.controllerName;
						}
					}
					// create controller
					if (bAsync) {
						oController = Controller.create({name: defaultController, _viewId: oThis.sId});
					} else {
						oController = sap.ui.controller(defaultController, true, false, oThis.sId); // legacy-relevant: Sync path
					}
				}
			} else {
				oThis.bControllerIsViewManaged = false;
				// if passed controller is not extended yet we need to do it.
				var sOwnerId = _runWithOwner.getCurrentOwnerId();
				if (!oController._isExtended()) {
					oController = Controller.applyExtensions(oController, sName, sOwnerId, oThis.sId, bAsync);
				} else if (bAsync) {
					oController = Promise.resolve(oController);
				}
			}

			if (oController) {
				if (bAsync) {
					if (!oThis.oAsyncState) {
						throw new Error("The view " + oThis.sViewName + " runs in sync mode and therefore cannot use async controller extensions!");
					}
					return oController.then(connectToView);
				} else {
					connectToView(oController);
				}
			}
		} else if (bAsync) {
			const oController = Object.assign(new Controller(), { "_sap.ui.core.mvc.EmptyControllerImpl": true });
			return Promise.resolve(oController).then(connectToView);
		} else {
			sap.ui.controller("sap.ui.core.mvc.EmptyControllerImpl", {"_sap.ui.core.mvc.EmptyControllerImpl":true}); // legacy-relevant: Sync path
			oThis.oController = sap.ui.controller("sap.ui.core.mvc.EmptyControllerImpl"); // legacy-relevant: Sync path
		}
	}
Creates and connects the controller if the controller is not given in the
mSettings

@param {sap.ui.core.mvc.XMLView} oThis the instance of the view that should be processed
@param {object} [mSettings] Settings
@returns {Promise|undefined} A promise for asynchronous or undefined for synchronous controllers
@throws {Error}
@private
@ui5-transform-hint replace-param mSettings.async true