有人可以解释 FW1 服务调用是如何工作的吗?当我阅读下面手册中的部分时。我认为以下应该有效。
参见:https ://github.com/seancorfield/fw1/wiki/Reference-Manual
服务方法被传递一组命名参数,基于控制器方法执行后请求上下文中的任何内容(即 before()、startItem() 和 item() 之后)。服务方法可能会返回一个结果,该结果由 FW/1 放入请求上下文中。默认情况下,FW/1 1.x 将(初始)服务方法调用的结果存储在 rc.data 中。
控制器/comparables.cfc
component {
public any function init( fw ) {
variables.fw = fw;
return this;
}
public void function autocomplete( rc ) {
// queue up a specific service (comparables.autocomplete) with named result (autocomplete)
var args = StructNew();
StructInsert( args, "table", "The Table" );
StructInsert( args, "column", "The Column" );
variables.fw.service( 'comparables.autocomplete', 'autocomplete', args );
}
}
服务/comparables.cfc
component {
public any function autocomplete( string table, string column, string term ) {
return "not yet implemented #table# #column# #term#";
}
}
以下视图显示 rc.autocomplete = "not yet implemented"
意见/可比性/autocomplete.cfm
<cfdump var="#variables.rc#" >