Skip to content

Commit 050e7b1

Browse files
committed
Update docs to match new Application/MyApplication structure
1 parent 5e0de4a commit 050e7b1

File tree

1 file changed

+50
-8
lines changed

1 file changed

+50
-8
lines changed

source/documentation/3.5/developing-applications.markdown

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: page
33
title: "Developing Applications with FW/1"
4-
date: 2015-09-05 14:30
4+
date: 2015-09-15 18:30
55
comments: false
66
sharing: false
77
footer: true
@@ -41,9 +41,16 @@ Instead of having your `Application.cfc` extend `framework.one`, you can use `/f
4141
component { // does not extend anything
4242
this.name = 'MyWonderfulApp';
4343
this.mappings[ '/framework' ] = expandPath( '/libs/fw1/framework' );
44-
request._framework_one = new framework.one( {
45-
trace : true
46-
} );
44+
function _get_framework_one() {
45+
if ( !structKeyExists( request, '_framework_one' ) ) {
46+
// create your FW/1 application:
47+
request._framework_one = new framework.one( {
48+
trace : true
49+
} );
50+
}
51+
return request._framework_one;
52+
}
53+
4754
// lifecycle methods, per /framework/Application.cfc
4855
...
4956
}
@@ -61,10 +68,45 @@ This works well when you cannot set a mapping in the CFML admin and you don't ne
6168
component { // does not extend anything
6269
this.name = 'MyWonderfulApp';
6370
this.mappings[ '/framework' ] = expandPath( '/libs/fw1/framework' );
64-
// create my extended version of FW/1:
65-
request._framework_one = new MyApplication( {
66-
trace : true
67-
} );
71+
function _get_framework_one() {
72+
if ( !structKeyExists( request, '_framework_one' ) ) {
73+
// create my extended version of FW/1:
74+
request._framework_one = new MyApplication( {
75+
trace : true
76+
} );
77+
}
78+
return request._framework_one;
79+
}
80+
81+
// lifecycle methods, per /framework/Application.cfc
82+
...
83+
}
84+
85+
Note that you can put your version of `MyApplication.cfc` anywhere and call it anything you want, as long as CFML can create an instance of it. A good strategy is to create a per-application mapping for your application's base folder and use that:
86+
87+
// /path/to/app/CustomApp.cfc
88+
component extends=framework.one {
89+
function setupRequest() {
90+
controller( 'security.checkAuthorization' );
91+
}
92+
}
93+
94+
// Application.cfc
95+
component { // does not extend anything
96+
this.name = 'MyWonderfulApp';
97+
this.mappings[ '/app' ] = expandPath( '/path/to/app' );
98+
this.mappings[ '/framework' ] = expandPath( '/libs/fw1/framework' );
99+
function _get_framework_one() {
100+
if ( !structKeyExists( request, '_framework_one' ) ) {
101+
// create my extended version of FW/1:
102+
request._framework_one = new app.CustomApp( {
103+
base : '/app',
104+
trace : true
105+
} );
106+
}
107+
return request._framework_one;
108+
}
109+
68110
// lifecycle methods, per /framework/Application.cfc
69111
...
70112
}

0 commit comments

Comments
 (0)