Created
June 7, 2013 14:03
-
-
Save JumboLove/5729476 to your computer and use it in GitHub Desktop.
Creating Pipeline Hooks
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
| GetPipelineHooks.ds | |
| /** | |
| * Name: GetHookPipeline.ds | |
| * | |
| * Description: | |
| * Gets the configiured hook pipeline, if not found it returns EmptyHook-Start | |
| * | |
| * @input hookName : String The property key of the Hook | |
| * @input fallbackHookPipeline : String The pipeline, which should be used as a fallback, if the hook is not defined in the current site | |
| * @output hookPipeline : String The hook pipeline to call | |
| * | |
| */ | |
| importPackage( dw.system ); | |
| importPackage( dw.web ); | |
| function execute( pdict : PipelineDictionary ) : Number { | |
| // the name of the resource bundle that stores the hooks | |
| var BUNDLE_KEY : String = "_hooks"; | |
| // define a default hook | |
| var hook : String ="EmptyHook-Start"; | |
| // check for configured fallback | |
| if (!empty(pdict.fallbackHookPipeline)) { | |
| hook = pdict.fallbackHookPipeline; | |
| } | |
| // check for configured pipeline hook name | |
| if (!empty(pdict.hookName)) { | |
| var configValue : String = Resource.msg(pdict.hookName,BUNDLE_KEY,""); | |
| if (!empty(configValue)) { | |
| hook = configValue; | |
| } | |
| } | |
| pdict.hookPipeline = hook; | |
| return PIPELET_NEXT; | |
| } | |
| Create EmptyHook-Start Pipeline or substitute other default empty Pipeline | |
| fallbackHookPipeline = null | |
| hookName = "cart.calculation" | |
| hookPipeline = CartCalculationHook | |
| ScriptLog = ScriptLog | |
| Call Node | |
| Use Pipeline from Dictionary Key CartCalculationHook | |
| _hooks.properties | |
| cart.calculation=TR_Custom-BasketCookieCallback |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment