我正在使用 CakePHP v2.4。
在模型的 afterSave()
回调中,我想根据请求的条件有条件地做一些事情。但是$this->request
似乎没有在这里定义:
public function afterSave( $created, $options=array() ) {
$this->log( $this->request ); //NOTHING HERE
}
我该怎么做?
最佳答案
您可以通过全局 Router 类访问它。
public function afterSave( $created, $options=array() ) {
$this->log( Router::getRequest() );
}
关于php - CakePHP:如何在模型中访问 $this->request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21139654/