2016-07-28 3 views
3

사용자에게 저장소에 대한 액세스 권한이 있는지 확인하는 기능이 있습니다.Symfony의 저장소 이름 가져 오기

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); 

이 경우 $REPOSITORYNAMEAppBundle:Client이거나 심지어는 Client

일까요? 있을 수 있습니다

+1

첫째, 당신은 여기 저장소와 처리하지 않는 질문을 이해하지 못했다 하지만 저장소 (repository)로부터 취득한'Client' (엔티티)의 인스턴스입니다. 또한'get_class()'함수를 검사하십시오. –

답변

2

t 방법이 있나요 그래서

$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); 

아니면 모든