Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active December 14, 2023 10:32
Show Gist options
  • Save stevewithington/6469763 to your computer and use it in GitHub Desktop.
Save stevewithington/6469763 to your computer and use it in GitHub Desktop.
Mura CMS : You can easily override nearly any method in Mura with method injection. This example shows you how to do that.
<cfscript>
// drop this in your eventHandler.cfc
public any function yourMethod() {
// you do something here
}
public any function onApplicationLoad($) {
arguments.$.getBean('someBean').injectMethod('someMethod', yourMethod);
}
</cfscript>
@jzuijlek
Copy link

jzuijlek commented Mar 7, 2014

How would one use this with the userBean? I'm trying to have transparent encryption/decryption of the user data.

@rasleen-narula
Copy link

Hi Steve,

I have followed the example above. Using method injection, I am able to successfully inject my custom function into 'getImageUrl()' in ContentManager:
$.getBean('contentManager').inject('getImageURL', customGetImageUrl);

Now I have been trying to override 'hasImage()' in ContentNavBean similar to above but seems like my changes are not getting recognized at all for this particular method.
$.getBean('contentNavBean').inject('hasImage', customHasImage);

I am not sure why is it that I am able to inject my custom function into contentManager but not into contentNavBean.
Has contentNavBean been exempted from method injection?

Please find the link below to Mura Google Groups for more information:
associated image for content type "File"

Thanks in advance,
Rasleen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment