我有一个检查用户是否有权访问存储库的函数。
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);
在这种情况下,{p> $REPOSITORYNAME
应该是AppBundle:Client
,或者只有Client
那可能吗? 有没有办法t
答案 0 :(得分:2)
可能是这样
$this->get('log')->writeLog('Access denied to '.get_class($repository).'.', __LINE__, 3);
或
$class = get_class($repository);
$this->get('log')->writeLog('Access denied to '.substr($class, strrpos($class, '\\') + 1).'.', __LINE__, 3);
或者我没有理解问题