Created
November 7, 2013 05:52
-
-
Save muracms/7349677 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| component extends="mura.cfobject"{ | |
| variables.dateManager = ""; | |
| public library function init(){ | |
| return this; | |
| } | |
| public any function getRandomValue() { | |
| return randRange(1,100); | |
| } | |
| public any function setDateManager(dateManager) { | |
| variables.dateManager = arguments.dateManager; | |
| } | |
| public any function getDateManager" output="false" { | |
| return variables.dateManager; | |
| } | |
| public any function setPluginConfig(pluginConfig) { | |
| variables.pluginConfig = arguments.PluginConfig; | |
| } | |
| public any function getPluginConfig" output="false" { | |
| return variables.pluginConfig; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| component extends="mura.cfobject"{ | |
| variables.library = ""; | |
| public dateManager function init(){ | |
| return this; | |
| } | |
| public any function getDate() { | |
| return now(); | |
| } | |
| public any function setLibrary(library) { | |
| variables.library=arguments.library; | |
| } | |
| public any function getLibrary" output="false" { | |
| return variables.library; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfscript> | |
| include "/plugin/config.cfm"; | |
| var pApp = variables.pluginConfig.getApplication(); | |
| var myLibrary = CreateObject('myLibrary', 'cfcs.library'); | |
| var myDateManager = CreateObject('dateManager', 'cfcs.dateManager'); | |
| pApp.setValue('library', myLibrary); | |
| pApp.setValue('dateManager', myDateManager); | |
| </cfscript> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| component extend="mura.plugin.pluginGenericEventHandler" { | |
| public any function onApplicationLoad($) { | |
| var myLibrary = CreateObject('myLibrary', 'cfcs.library'); | |
| var myDateManager = CreateObject('dateManager', 'cfcs.dateManager'); | |
| var pApp = variables.pluginConfig.getApplication(); | |
| pApp.setValue('library', myLibrary); | |
| pApp.setValue('dateManager', myDateManager); | |
| } | |
| public any function onMyCustomEvent($){ | |
| var pApp = variables.pluginConfig.getApplication(); | |
| var myLibrary = pApp.getValue('library'); | |
| /* | |
| The dateManager was never explicitly set or created; | |
| instead, we have accessed it via auto-wiring | |
| */ | |
| var myDateManager = library.getDateManager(); | |
| /* | |
| The pluginConfig is also never explicitly set. But since the plugin | |
| application object knows what plugin is belongs to it can automatically | |
| set it as well | |
| */ | |
| var pluginConfig = library.getPluginConfig(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| component extends="mura.plugin.pluginGenericEventHandler"{ | |
| public any function onApplicationLoad($){ | |
| variables.pluginConfig.addEventHandler(this); | |
| } | |
| public any function onCustomEvent($){ | |
| //do custom stuff | |
| } | |
| public any function onAnotherCustomEvent($){ | |
| //do custom stuff | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment