doujiu4643 2017-11-03 21:36
浏览 48
已采纳

cakephp-3.4 immutable http equest api API

In cakephp 3.3 I could use statement like this in controller:

$this->request->data = array_merge($this->request->query,$this->request->data);

How can I achieve the same effect using new immutable httpequest api API i n cake 3.4/3.5?

  • 写回答

1条回答 默认 最新

  • douchilian1009 2017-11-13 15:35
    关注

    So it's quite bad practice to overwrite (or even append to) the request, since this is what the client has sent - if you really still want to go that way, one could use reflection to set the value... Did I mention this is bad practice?

    Like.. really bad practice :)

    $reflectionClass = new ReflectionObject($this->request);
    $reflectionProperty = $reflectionClass->getProperty('data');
    $reflectionProperty->setAccessible(true);
    $reflectionProperty->setValue($this->request, -YourNewArray-);
    

    I guess I don't have to repeat that what already has been said, but if it saves you the problem of upgrading between versions.. this might fix it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大