Callbacks for plugins

0 views
Skip to first unread message

Andy Bellenie

unread,
Nov 5, 2009, 5:07:40 AM11/5/09
to ColdFusion on Wheels
I think it would be very useful to be able to add callback events to
plugins, i.e:

<cfcomponent>

<cffunction name="init" access="public" output="false"
returntype="any">
<cfset this.version = 1.0 />
<cfset afterInitialization(methods="$myMethod")>
<cfreturn this />
</cffunction>

Thoughts?

m...@iamjamesgibson.com

unread,
Nov 5, 2009, 6:44:03 AM11/5/09
to ColdFusion on Wheels
Hey Andy,

You can do this, but not like you describe above. Check out my Nested
Set plugin in the actsAsNestedSet() method. I setup events to happen
within the method and create new event types that can occur when the
plugin is initialized in the model. Hope this helps.

James

Andy Bellenie

unread,
Nov 5, 2009, 7:27:10 AM11/5/09
to cfwh...@googlegroups.com
Hi James,

Actually it was that plugin that was making me think about it. What I
was looking for was a way of calling the validation method after the
plugin has been mixed into the model, to avoid having to call it on
the accessors.

I'm just finishing off some changes to this - I haven't quite worked
out how to put it up on github though. I've created a fork but when I
edited my version of it the changes never seemed to get saved...

Andy

2009/11/5 m...@iamjamesgibson.com <m...@iamjamesgibson.com>:

m...@iamjamesgibson.com

unread,
Nov 5, 2009, 8:13:56 AM11/5/09
to ColdFusion on Wheels
Hey Andy,

> Actually it was that plugin that was making me think about it. What I
> was looking for was a way of calling the validation method after the
> plugin has been mixed into the model, to avoid having to call it on
> the accessors.

Unfortunately the plugin methods are mixed into the model in
onApplicationStart() which means they are mixed in before the request
is started.

> I'm just finishing off some changes to this - I haven't quite worked
> out how to put it up on github though. I've created a fork but when I
> edited my version of it the changes never seemed to get saved...

Git is a little different from SVN in the sense that it is
distributed. This means that we are currently working with 4 full
repositories (my local, my github, your github fork and your local).
To get the changes up to github, you would need to push the changes up
to your fork with something like:

git push origin master

This should work from the get go if you cloned your fork down to your
computer. If you did a git init on a local directory you will need to
let the local repo know about github.

Check out http://help.github.com/ and http://learn.github.com/ .

Best,
James
Reply all
Reply to author
Forward
0 new messages