There is the following function in the controller.php of framework thinkphp used in a project, where there is this line of codes: "$conf = $this->$action".
"if (property_exists($this, $action))" is checking if there exists property $action in the class $this. Form the next line of codes "if (key_exists('login', $conf))", it looks to me that $conf is an array.
My question is: what exactly is "$conf = $this->$action" doing, assigning an array (the property $action? why $action is an array?) to the variable $conf?
public function checkAccessControl()
{
if (Config::get('frame.controller.checkAccessControl.exec')) {
$action = $this->request ->action(true);
if (property_exists($this, $action)) {
$conf = $this->$action;
if (key_exists('login', $conf)) {
if ($conf['login'] === true && $this->if_login === false) {
$this->access_control_check = false;
$this->response(["error"=>"未登录用户无权访问"],[],401,'json');//要求用户的身份认证
} else {
$this->access_control_check = true;
}
} else {
$this->access_control_check = false;
$this->response(["error"=>"代码错误:未标注访问类型"],[],500);//服务器内部错误,无法完成请求(未在控制器中标注login的访问控制)
}
} else {
$this->access_control_check = false;
$this->response(["error"=>"代码错误:未标注访问控制"],[],500,'json',['action'=>$this->request->action(true)]);//服务器内部错误,无法完成请求(未在控制器中标注方法的访问控制)
}
} else {
$this->access_control_check = Config::get('frame.controller.checkAccessControl.default.access_control_check');
}
}