在 cakephp 3.3 中,我可以在控制器中使用这样的语句:
$this->request->data = array_merge($this->request->query,$this->request->data);
如何在 cake 3.4/3.5 中使用新的不可变 http\request api API 达到相同的效果?
在 cakephp 3.3 中,我可以在控制器中使用这样的语句:
$this->request->data = array_merge($this->request->query,$this->request->data);
如何在 cake 3.4/3.5 中使用新的不可变 http\request api API 达到相同的效果?
因此,覆盖(甚至附加到)请求是非常糟糕的做法,因为这是客户端发送的内容 - 如果您真的仍然想这样做,可以使用反射来设置值......我提到过吗是不好的做法?
就像..真的很糟糕的做法:)
$reflectionClass = new ReflectionObject($this->request);
$reflectionProperty = $reflectionClass->getProperty('data');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($this->request, -YourNewArray-);
我想我不必重复已经说过的话,但是如果它可以为您节省版本之间升级的问题..这可能会解决它。