cakecakephp有人能解释$this->;请求->;params[';pass';][0];


cakecake php Can someone explain $this->request->params['pass'][0];?

http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

我在cakepp网站上学习这个教程。我被这个卡住了

public function isAuthorized($user) {
        // All registered users can add posts
        if ($this->action === 'add') {
            return true;
        }
        if (in_array($this->action, array('edit', 'delete'))) {
            $postId = $this->request->params['pass'][0]; //what is this?
            if ($this->Post->isOwnedBy($postId, $user['id'])) {
                return true;
            }
        }
        return parent::isAuthorized($user);
    }

这是什么意思?我知道$this指的是控制器,但什么是param['pass'],他们在哪里以及如何获得它?

$postId = $this->request->params['pass'][0];

这些是在请求字符串或后变量中传递的参数。

http://book.cakephp.org/2.0/en/controllers/request-response.html

CakeRequest公开了几个用于访问请求的接口参数。第一个是作为对象属性,第二个是数组索引,第三个是通过$this->request->params:

不确定这是否是最好的答案,但我所要做的就是返回错误的

if ($this->Post->isOwnedBy($postId, $user['id'])) {
                return true;
            }else {
                return false;
            }