dty3416 2018-12-10 17:55
浏览 17
已采纳

超过10个嵌套前锋?

My project requires multiple payment gateways, so I set up a module per payment gateway and bound the appropriate payment gateway to the account that was using it. I then placed all payment code within the appropriate module controller. All gateways implement the same interface to ensure functions exist.

I am now running a nightly cron to charge payments against each account. The issue I'm getting is that in order to get the appropriate controller to run, I am using the following code inside a foreach loop:

$response = $this->forward()->dispatch(sprintf('PaymentGateway\%s\Controller\Index', ucwords($pg->code)), $params);

where $pg->code is the payment gateway assigned to the account.

At the moment I have two payment gateways (this will be going up in the near future) with about 20 test payments to be processed each. When I run the cron command I am getting the error:

Circular forwarding detected: greater than 10 nested forwards

In this scenario I need it to run 40 times, but that will go up in the future as more payment gateways are added and more transactions are queued.

In terms of a solution, I am looking to either

  • disable this check for the purposes of my cron or,
  • find an alternative to $this->forward()->dispatch(...); that will still allow me to call a different controller multiple times with custom parameters.

The alternative is that I pass in all transactions to each respective payment gateway and only call $this->forward()->dispatch() once per gateway, but I'll hit this issue again when I get to ten payment gateways.

  • 写回答

1条回答 默认 最新

  • duancan65665 2018-12-11 09:34
    关注

    The forward controller plugin allows you to set the maximum number of nested forwards.

    Before my loop I set the max number of nested forwards to the number of items I was going to loop through:

    $this->forward()->setMaxNestedForwards(count($transactions));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址