The DSL Builder Interface

IDSLBuilder

The scope interface can be found here: coldbox.system.ioc.dsl.IDSLBuilder.

/**
 * Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
 * www.ortussolutions.com
 * ---
 * The main interface to produce WireBox namespace DSL Builders
 **/
interface {

	/**
	 * Configure the DSL Builder for operation and returns itself
	 *
	 * @injector             The linked WireBox Injector
	 * @injector.doc_generic coldbox.system.ioc.Injector
	 *
	 * @return coldbox.system.ioc.dsl.IDSLBuilder
	 */
	function init( required injector );

	/**
	 * Process an incoming DSL definition and produce an object with it
	 *
	 * @definition   The injection dsl definition structure to process. Keys: name, dsl
	 * @targetObject The target object we are building the DSL dependency for. If empty, means we are just requesting building
	 * @targetID     The target ID we are building this dependency for
	 *
	 * @return coldbox.system.ioc.dsl.IDSLBuilder
	 */
	function process( required definition, targetObject, targetID );

}

Your DSL Builder

Here is a sample DSL builder:

Here is another one that you can find in the ColdBox ORM module: https://github.com/coldbox-modules/cborm/tree/development/dsl

Registration

In your configuration binder you can then register the DSL component you created

This will register a new injection DSL namespace called ortus that maps to that instantiation component path.model.dsl.OrtusBuilder.

As you can see from the sample, creating your own DSL builder is fairly easy. The benefits of a custom DSL builder is that you can very easily create and extend the injection DSL language to your own benefit and if you are funky enough, override the behavior of the internal DSL Namespaces.

Last updated

Was this helpful?