forked from deftjs/DeftJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tracing DeftJS Controller Inheritance for debugging. Modified t…
…o only allow the first defined controller, rather than the last superclass.
- Loading branch information
1 parent
09d206d
commit 971dc02
Showing
1 changed file
with
23 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -636,7 +636,7 @@ Ext.define('Deft.mvc.ViewController', { | |
Ext.define('Deft.mixin.Controllable', {}); | ||
|
||
Ext.Class.registerPreprocessor('controller', function (Class, data, hooks, callback) { | ||
var controllerClass, originalConstructor, originalDestroy, parameters, self; | ||
var controllerClass, originalConstructor, originalDestroy, parameters, self, controllerState, superclassController; | ||
if (arguments.length === 3) { | ||
parameters = Ext.toArray(arguments); | ||
hooks = parameters[1]; | ||
|
@@ -646,6 +646,13 @@ Ext.Class.registerPreprocessor('controller', function (Class, data, hooks, callb | |
controllerClass = data.controller; | ||
delete data.controller; | ||
if (controllerClass != null) { | ||
|
||
This comment has been minimized.
Sorry, something went wrong. |
||
if (!this.__proto__.controllerState) { | ||
this.__proto__.controllerState = {deftJS : {currentController : undefined, controllerChain : {attempted : [], processed : []}}}; | ||
} | ||
controllerState = this.__proto__.controllerState; | ||
controllerState.deftJS.controllerChain.attempted.push({id : Ext.id(undefined, 'attempted-controller'), class : controllerClass}); | ||
|
||
if (!data.hasOwnProperty('constructor')) { | ||
data.constructor = function () { | ||
return this.callParent(arguments); | ||
|
@@ -657,12 +664,22 @@ Ext.Class.registerPreprocessor('controller', function (Class, data, hooks, callb | |
if (config == null) { | ||
config = {}; | ||
} | ||
try { | ||
controller = Ext.create(controllerClass, config.controllerConfig || this.controllerConfig || {}); | ||
} catch (error) { | ||
Deft.Logger.warn("Error initializing Controllable instance: an error occurred while creating an instance of the specified controller: '" + controllerClass + "'."); | ||
throw error; | ||
// TODO - This is too brute force, only accepts the first controller to be defined. That controller then must manage it's own 'Deft.mvc.ViewController' inheritance. | ||
if (controllerState.deftJS.controllerChain.processed.length > 0) { | ||
This comment has been minimized.
Sorry, something went wrong.
cnstaging
Owner
|
||
//superclassController = Class && Class.controller ? Class.superclass.controller : false; | ||
console.warn("We should stop and do something here!"); | ||
controller = controllerState.deftJS.currentController; | ||
} else { | ||
controllerState.deftJS.controllerChain.processed.push(controllerClass); | ||
try { | ||
controller = Ext.create(controllerClass, config.controllerConfig || this.controllerConfig || {}); | ||
controllerState.deftJS.currentController = controller; | ||
} catch (error) { | ||
Deft.Logger.warn("Error initializing Controllable instance: an error occurred while creating an instance of the specified controller: '" + controllerClass + "'."); | ||
throw error; | ||
} | ||
} | ||
|
||
this.getController = function () { | ||
return controller; | ||
}; | ||
|
Here we setup some Tracing DeftJS Controller Inheritance for debugging, even though there is no flag to turn it off.
Also messing with prototypes like this is messy, again only used for debugging in our testing.