Hi,
I have a transfer decorator object and want to be able to use
functionality of a model called utils - iow inject the transfer
decorator with a model dependency. I have this (code snippets):
my transfer decorator object in models/decorators/menuDecorator.cfc
contains:
<cfcomponent output="false" extends="transfer.com.TransferDecorator"
autowire="true">
<cfproperty name="utils" type="ocm:utils" scope="variables">
<cffunction name="addMenuItem" output="false">
<cfargument name="rc" type="Struct">
<cfset var local={}>
<cfdump var="#ocm#">
<cfabort>
This gives me a "Variable OCM is undefined." error.
This is my code (snippets):
1) coldbox.xml:
<!-- USE AUTOWIRING -->
<Interceptor class="coldbox.system.interceptors.autowire">
<Property name="debugMode">false</Property>
<Property name="completeDIMethodName">onDIComplete</Property>
<Property name="enableSetterInjection">false</Property>
</Interceptor>
<!-- Transfer Loader -->
<Interceptor class="coldbox.system.extras.transfer.TransferLoader">
<Property name="ConfigPath">/transfer/config/transfer.xml</
<Property name="definitionPath">/transfer/config/definitions</
<Property name="datasourceAlias">cms</Property>
</Interceptor>
2) transfer.xml:
<!-- This table contains metadata for menuitems -->
<object name="menu" table="menus"
decorator="model.decorators.menuDecorator">
...
3) models/decorators/menuDecorator.cfc:
<cfcomponent output="false" extends="transfer.com.TransferDecorator">
<cfproperty name="utils" type="ocm:utils" scope="variables">
<cfproperty name="ocm" type="ocm" scope="variables">
<cffunction name="addMenuItem" output="false">
<cfargument name="rc" type="Struct">
<cfset var local={}>
<cfdump var="#ocm#">
<cfabort>
This last functiuon is called from a model called menu. Right now I
solved my problem by moving the code I needed the utils model
functionality for from te menuDecorator to my menu model. I use DI
there and sent the result as an argument to the menuDecorator
function.
Just wondering - is it possible _at all_ to use DI on a transfer
object? I can't believe it is not since am able to use DI on other
objects.
What did I leave out that this doesn't work?
Thanks,
Marc