MapDirectory() Influence & Filters
The mapDirectory() allows you to leverage closures or lambdas to influence and filter mappings. The arguments are filter to add a filter that MUST return boolean in order to process the mapping and influence that can influence the created mapping with any custom bindings.
1
// influence only certain components to be singleton
2
mapDirectory(packagePath="coldbox.testing.testModel.ioc", influence=function(binder, path){
3
if( findNoCase( "simple", arguments.path) ){
4
arguments.binder.asSingleton();
5
}
6
});
7
8
// filter some components from registration
9
mapDirectory(packagePath="coldbox.testing.testModel.ioc", filter=function(path){
10
return ( findNoCase( "simple", arguments.path ) ? false : true );
11
});
Copied!
Copy link