我目前正在尝试扩展第三方 CFC,一切正常并且工作正常,但是,我现在已经覆盖了 CFC 中的一个方法(我首先扩展它的全部原因)。现在第三方 CFC 都是基于标签的,并且有一个名为“do”的函数 - 定义如下:
<cffunction name="do" returntype="any" access="public" output="true"
hint="I compile and execute a specific fuseaction.">
<cfargument name="action" type="string" required="true"
hint="I am the full name of the requested fuseaction (circuit.fuseaction)." />
<cfargument name="contentVariable" type="string" default=""
hint="I indicate an attributes / event scope variable in which to store the output." />
<cfargument name="returnOutput" type="boolean" default="false"
hint="I indicate whether to display output (false - default) or return the output (true)." />
<cfargument name="append" type="boolean" default="false"
hint="I indicate whether to append output (false - default) to the content variable." />
<cfargument name="passThroughReturn" type="boolean" default="false"
hint="I indicate whether to allow for a return to be passed through from an action CFC." />
现在,我的 CFC 都是 cfscript(我的个人偏好和项目编码标准)。如果我尝试在我的 CFC 中覆盖此方法,如下所示:
public any function do( Required String action, String contentVariable="", boolean returnOutput=false, boolean append=false, boolean passThroughReturn=false){
然后我得到一个关于函数名的错误,假设是因为“do”是一个 CF 保留字。
我试图通过重命名方法并仅映射来解决这个问题,例如:
this.do = variables.invokeDo;
public any function invokeDo( Required String action, String contentVariable="", boolean returnOutput=false, boolean append=false, boolean passThroughReturn=false){
这绕过了错误,但如果我调用myObject.do(..)
它只是调用超类方法。
有谁知道我如何在 CFscript 中覆盖这个方法?