Hi,
Is is possible to use ColdBox as a Transient Factory?
I looked at the example on the cbModelGuid wiki page [http://
ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbModelGuide] and it is
creating the User with a CreateObject function.
I know that I could use the IoC plugin and Lightwire as a Transient
Factory, but can you use the GetModel("User") to do something like:
<cfcomponent name="UserService" output="false" cache="true"
cacheTimeout="0">
<!--- Dependencies --->
<cfproperty name="SessionStorage"
type="coldbox:plugin:sessionstorage" scope="instance" />
<cfproperty name="HandlerService" type="coldbox:handlerService"
scope="instance" />
<cfscript>
instance = structnew();
</cfscript>
<cffunction name="init" output="false" returntype="UserService">
<cfreturn this>
</cffunction>
<cffunction name="getUserSession" output="false" access="public"
returntype="User"
hint="This method checks if a user is in an
authorized session, else it returns the default user object.">
<cfscript>
var oUser = "";
//Is user in session
if ( instance.sessionstorage.exists( 'CurrentUser' ) )
{
oUser = instance.sessionstorage.getVar
( 'CurrentUser' );
}
else{
oUser = instance.HandlerService.GetModel
("User");
}
/* Return User Object */
return oUser;
</cfscript>
</cffunction>
</cfcomponent>
Thanks!