CFLib.org – Common Function Library Project

getComponentProps(object)

Last updated September 21, 2010

Version: 3 | Requires: ColdFusion MX | Library: DataManipulationLib

 
Rated 1 time(s). Average Rating: 1.0

Description:
Pass in the result from getMetaData() and returns all properties within the cfc and those it extends. It is recursive. (I didn't find any true time difference and this seemed cleaner). This does not include the base 'component' tag in it's search. I couldn't see anyone putting properties there anyways. A special value will be added to each propery, foundIn, that represents which CFC a property was found in. This is useful in case both a child and parent CFC share the same property.

Return Values:
Returns an array of structs.

Example:

view plain print about
<cfset whatever = createobject('component', 'foo.bar')>
<cfset dummyArray = getComponentProps( getMetaData( whatever ))>
<cfdump var="#dummyArray#" />

Parameters:

Name Description Required
object The metadata from a component. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Returns an array of all properties in cfc's metadata, inherited or not.
 * v2 was submitted by salvatore fusto
 * v3 ditto
 * 
 * @param object      The metadata from a component. (Required)
 * @return Returns an array of structs. 
 * @author Robby Lansaw (robby@ohsogooey.com) 
 * @version 3, September 21, 2010 
 */

function getComponentProps(object) {
       var propArray = arrayNew(1);
       if (structKeyExists(object,'properties')) {
               propArray = object.properties
       }
       if (structKeyExists(object,'extends')) {
               propArray.addAll(getComponentProps(object.extends ))
       }
       return propArray;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson