public
Description: Shade is a state machine (or workflow) engine for ColdFusion business objects.
Homepage:
Clone URL: git://github.com/ryanwood/shade.git
shade / StateTransitionCollection.cfc
100644 34 lines (28 sloc) 1.014 kb
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
<cfcomponent displayname="StateTransitionCollection" extends="shade.CollectionBase" output="false">
 
<cffunction name="init" access="public" output="false">
<cfset super.init() />
<cfreturn this />
</cffunction>
 
<cffunction name="getMemento" access="public" output="false">
<cfset var a = arrayNew(1) />
<cfset reset() />
<cfloop condition="hasNext()">
<cfset arrayAppend(a, next().getMemento()) />
</cfloop>
<cfreturn a />
</cffunction>
 
 
<cffunction name="getTransitionsFromState" access="public" output="false">
<cfargument name="state" type="string" required="true" />
<cfset var i = 1 />
<cfset var fromState = createObject("component", "shade.StateTransitionCollection").init() />
<cfset var transition = "" />
 
<cfset reset() />
<cfloop condition="hasNext()">
<cfset transition = next() />
<cfif transition.getFromState() eq arguments.state>
<cfset fromState.add(transition) />
</cfif>
</cfloop>
<cfreturn fromState />
</cffunction>
 
</cfcomponent>