src/sap.ui.core/src/sap/ui/core/mvc/View.js
function(oThis, mSettings) {

		if (!sap.ui.getCore().getConfiguration().getControllerCodeDeactivated()) {
			// only set when used internally
			var oController = mSettings.controller,
				sName = oController && typeof oController.getMetadata === "function" && oController.getMetadata().getName(),
				bAsync = mSettings.async;

			if (!oController && oThis.getControllerName) {
				// get optional default controller name
				var defaultController = oThis.getControllerName();
				if (defaultController) {
					// check for controller replacement
					var CustomizingConfiguration = sap.ui.require('sap/ui/core/CustomizingConfiguration');
					var sControllerReplacement = CustomizingConfiguration && CustomizingConfiguration.getControllerReplacement(defaultController, ManagedObject._sOwnerId);
					if (sControllerReplacement) {
						defaultController = typeof sControllerReplacement === "string" ? sControllerReplacement : sControllerReplacement.controllerName;
					}
					// create controller
					if (bAsync) {
						oController = Controller.create({name: defaultController});
					} else {
						oController = sap.ui.controller(defaultController, true /* oControllerImpl = true: do not extend controller inside factory; happens below (potentially async)! */);
					}
				}
			} else if (oController) {
				// if passed controller is not extended yet we need to do it.
				var sOwnerId = ManagedObject._sOwnerId;
				if (!oController._isExtended()) {
					if (bAsync) {
						oController = Controller.extendByCustomizing(oController, sName, bAsync)
							.then(function(oController) {
								return Controller.extendByProvider(oController, sName, sOwnerId, bAsync);
							});
					} else {
						oController = Controller.extendByCustomizing(oController, sName, bAsync);
						oController = Controller.extendByProvider(oController, sName, sOwnerId, bAsync);
					}
				} else if (bAsync) {
					oController = Promise.resolve(oController);
				}
			}

			if ( oController ) {
				var connectToView = function(oController) {
					oThis.oController = oController;
					oController.oView = oThis;
				};

				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 {
			sap.ui.controller("sap.ui.core.mvc.EmptyControllerImpl", {"_sap.ui.core.mvc.EmptyControllerImpl":true});
			oThis.oController = sap.ui.controller("sap.ui.core.mvc.EmptyControllerImpl");
		}
	}
function(oThis, mSettings) {

		if (!sap.ui.getCore().getConfiguration().getControllerCodeDeactivated()) {
			// only set when used internally
			var oController = mSettings.controller,
				sName = oController && typeof oController.getMetadata === "function" && oController.getMetadata().getName(),
				bAsync = mSettings.async;

			if (!oController && oThis.getControllerName) {
				// get optional default controller name
				var defaultController = oThis.getControllerName();
				if (defaultController) {
					// check for controller replacement
					var CustomizingConfiguration = sap.ui.require('sap/ui/core/CustomizingConfiguration');
					var sControllerReplacement = CustomizingConfiguration && CustomizingConfiguration.getControllerReplacement(defaultController, ManagedObject._sOwnerId);
					if (sControllerReplacement) {
						defaultController = typeof sControllerReplacement === "string" ? sControllerReplacement : sControllerReplacement.controllerName;
					}
					// create controller
					if (bAsync) {
						oController = Controller.create({name: defaultController});
					} else {
						oController = sap.ui.controller(defaultController, true /* oControllerImpl = true: do not extend controller inside factory; happens below (potentially async)! */);
					}
				}
			} else if (oController) {
				// if passed controller is not extended yet we need to do it.
				var sOwnerId = ManagedObject._sOwnerId;
				if (!oController._isExtended()) {
					if (bAsync) {
						oController = Controller.extendByCustomizing(oController, sName, bAsync)
							.then(function(oController) {
								return Controller.extendByProvider(oController, sName, sOwnerId, bAsync);
							});
					} else {
						oController = Controller.extendByCustomizing(oController, sName, bAsync);
						oController = Controller.extendByProvider(oController, sName, sOwnerId, bAsync);
					}
				} else if (bAsync) {
					oController = Promise.resolve(oController);
				}
			}

			if ( oController ) {
				var connectToView = function(oController) {
					oThis.oController = oController;
					oController.oView = oThis;
				};

				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 {
			sap.ui.controller("sap.ui.core.mvc.EmptyControllerImpl", {"_sap.ui.core.mvc.EmptyControllerImpl":true});
			oThis.oController = sap.ui.controller("sap.ui.core.mvc.EmptyControllerImpl");
		}
	}
function ( oThis , mSettings ) { if ( ! sap . ui . getCore ( ) . getConfiguration ( ) . getControllerCodeDeactivated ( ) ) { // only set when used internally var oController = mSettings . controller , sName = oController && typeof oController . getMetadata === "function" && oController . getMetadata ( ) . getName ( ) , bAsync = mSettings . async ; if ( ! oController && oThis . getControllerName ) { // get optional default controller name var defaultController = oThis . getControllerName ( ) ; if ( defaultController ) { // check for controller replacement var CustomizingConfiguration = sap . ui . require ( 'sap/ui/core/CustomizingConfiguration' ) ; var sControllerReplacement = CustomizingConfiguration && CustomizingConfiguration . getControllerReplacement ( defaultController , ManagedObject . _sOwnerId ) ; if ( sControllerReplacement ) { defaultController = typeof sControllerReplacement === "string" ? sControllerReplacement : sControllerReplacement . controllerName ; } // create controller if ( bAsync ) { oController = Controller . create ( { name : defaultController } ) ; } else { oController = sap . ui . controller ( defaultController , true /* oControllerImpl = true: do not extend controller inside factory; happens below (potentially async)! */ ) ; } } } else if ( oController ) { // if passed controller is not extended yet we need to do it. var sOwnerId = ManagedObject . _sOwnerId ; if ( ! oController . _isExtended ( ) ) { if ( bAsync ) { oController = Controller . extendByCustomizing ( oController , sName , bAsync ) . then ( function ( oController ) { return Controller . extendByProvider ( oController , sName , sOwnerId , bAsync ) ; } ) ; } else { oController = Controller . extendByCustomizing ( oController , sName , bAsync ) ; oController = Controller . extendByProvider ( oController , sName , sOwnerId , bAsync ) ; } } else if ( bAsync ) { oController = Promise . resolve ( oController ) ; } } if ( oController ) { var connectToView = function ( oController ) { oThis . oController = oController ; oController . oView = oThis ; } ; 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 { sap . ui . controller ( "sap.ui.core.mvc.EmptyControllerImpl" , { "_sap.ui.core.mvc.EmptyControllerImpl" : true } ) ; oThis . oController = sap . ui . controller ( "sap.ui.core.mvc.EmptyControllerImpl" ) ; } }
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
Creates and connects the controller if the controller is not given in the mSettings