Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在cakephp中为行为方法提供传递引用参数?_Cakephp_Cakephp 2.0_Pass By Reference_Behavior - Fatal编程技术网

如何在cakephp中为行为方法提供传递引用参数?

如何在cakephp中为行为方法提供传递引用参数?,cakephp,cakephp-2.0,pass-by-reference,behavior,Cakephp,Cakephp 2.0,Pass By Reference,Behavior,根据, 我可以做到以下几点: public function fly(Model $Model, $from, $to) { // Do some flying. } 我希望在behavior方法中有一个按引用传递的参数 这是我的方法: public function extractByFields(Model $model, $data, $options = array(), Array $missingFields) { 我希望通过引用传递的参数是$missingFields

根据,

我可以做到以下几点:

public function fly(Model $Model, $from, $to) {
    // Do some flying.
}
我希望在behavior方法中有一个按引用传递的参数

这是我的方法:

public function extractByFields(Model $model, $data, $options = array(), Array $missingFields) {
我希望通过引用传递的参数是
$missingFields

原因是我想返回我的
$foundFields
,但如果有任何其他缺少的字段,我还想将它们公开给方法调用方

如果CakePHP不能允许我在我的行为方法中返回通过引用传递的参数,那么我想了解一些关于如何最好地进行变通的建议


我的版本是CakePHP2.4

,使用的行为方法不能使用通过引用传递的参数。call_user_func_array()用于调用方法,参数不通过引用传递


可能的解决方法:将行为类中缺少的字段存储为属性,并有一个方法来检索它们。

只是想补充一点,我采用了Ceeram建议的解决方法。我将$missingFields存储为私有属性,并使用单独的方法检索它们