-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathModuleConfig.cfc
91 lines (79 loc) · 2.72 KB
/
ModuleConfig.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
component {
this.name = "quick";
this.author = "Eric Peterson";
this.webUrl = "https://github.com/coldbox-modules/quick";
this.dependencies = [ "qb", "str", "mementifier" ];
this.cfmapping = "quick";
function configure() {
settings = {
"defaultGrammar" : "AutoDiscover@qb",
"defaultQueryOptions" : {},
"preventDuplicateJoins" : true,
"metadataCache" : {
"name" : "quickMeta",
"provider" : "coldbox.system.cache.providers.CacheBoxColdBoxProvider",
"properties" : {
"objectDefaultTimeout" : 0, // no timeout
"useLastAccessTimeouts" : false, // no last access timeout
"maxObjects" : 300,
"objectStore" : "ConcurrentStore"
}
}
};
interceptorSettings = {
customInterceptionPoints : [
"quickInstanceReady",
"quickPreLoad",
"quickPostLoad",
"quickPreSave",
"quickPostSave",
"quickPreInsert",
"quickPostInsert",
"quickPreUpdate",
"quickPostUpdate",
"quickPreDelete",
"quickPostDelete"
]
};
binder.map( "quick.models.BaseEntity" ).to( "#moduleMapping#.models.BaseEntity" );
binder.getInjector().registerDSL( "quickService", "#moduleMapping#.dsl.QuickServiceDSL" );
}
function onLoad() {
binder
.map( alias = "QuickQB@quick", force = true )
.to( "#moduleMapping#.models.QuickQB" )
.initArg( name = "grammar", dsl = settings.defaultGrammar )
.initArg( name = "preventDuplicateJoins", value = settings.preventDuplicateJoins )
.initArg( name = "defaultOptions", value = settings.defaultQueryOptions )
.initArg( name = "utils", dsl = "QueryUtils@qb" )
.initArg( name = "sqlCommenter", ref = "ColdBoxSQLCommenter@qb" )
.initArg( name = "returnFormat", value = "array" );
if ( isSimpleValue( settings.metadataCache ) ) {
settings.metadataCache = { "name" : settings.metadataCache };
}
if ( settings.metadataCache.name != "quickMeta" ) {
binder.map( "cachebox:quickMeta" ).toDSL( "cachebox:#settings.metadataCache.name#" );
} else {
wirebox.getCachebox().createCache( argumentCollection = settings.metadataCache );
}
}
function onUnload() {
wirebox
.getCachebox()
.getCache( settings.metadataCache.name )
.clearAll();
}
/**
* This interceptor ensures that the `_mapping` property for a Quick entity
* is correctly set to the mapping used in WireBox.
*
* @event The current request context
* @interceptData The intercept data for `afterInstanceAutowire`.
* { mapping, target, targetID, injector }
*/
function beforeInstanceAutowire( event, interceptData ) {
if ( structKeyExists( interceptData.target, "isQuickEntity" ) ) {
interceptData.target.set_mapping( interceptData.targetID );
}
}
}