3
我有一個函數檢查用戶是否有權訪問存儲庫。在Symfony中獲取存儲庫var的名稱
public function getACL($repository, $granted){
if (false === $this->authorizationChecker->isGranted($granted, $repository)) {
$this->get('log')->writeLog('Access denied.', __LINE__, 3);
return new JsonResponse(array(
'result' => 'error',
'message' => 'Not allowed'
));
}
return true;
}
呼叫
/* Get Client */
$client = $em->getRepository('AppBundle:Client')->find($request->get('clientId'));
/* Get ACL */
$this->get('global_functions')->getACL($client, 'VIEW');
我希望得到什麼
我想看到用戶已被拒絕存儲庫的名稱,像這樣:
$this->get('log')->writeLog('Access denied to $REPOSITORYNAME.', __LINE__, 3);
在這種情況下$REPOSITORYNAME
應該是AppBundle:Client
甚至只有Client
這是否可能? 是有辦法牛逼
首先,你不處理庫在這裏,但它是從庫中檢索到的'Client'(實體)的一個實例。同時檢查'get_class()'函數。 –