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()'函数。 –