Skip to content

Instantly share code, notes, and snippets.

@cameroncf
Last active June 1, 2016 00:27
Show Gist options
  • Save cameroncf/687c049cb79003ac0afff9b52054f528 to your computer and use it in GitHub Desktop.
Save cameroncf/687c049cb79003ac0afff9b52054f528 to your computer and use it in GitHub Desktop.
// all ORM entities need to extend me
conponent
{
public any function getService( required string objectName ) {
getBeanFactory().getBean( arguments.objectName );
}
private any function getBeanFactory() {
return application[ request.framework_applicationKey ].factory; // get DI/1 factory
}
}
// Example ORM bean that inherits the ability to use DI/1 BeanFactory
compoment
extends = "DIAwareORMBean"
{
var someService = getService('Anything-In-DI-Bean-Factory');
}
// Example ORM bean that Programmatically accesses DI/1 BeanFactory
compoment
{
var someService = new DIAwareORMBean().getService('Anything-In-DI-Bean-Factory');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment