2
예를 들어 Zend_Acl_Assert_Interface에서 파생 된 클래스에 assert 메서드가 구현되어 있습니다.isAllowed 사용 후 오류 메시지 표시
function assert(
Zend_Acl $acl,
Zend_Acl_Role_Interface $user = null,
Zend_Acl_Resource_Interface $item = null,
$privilege = null
) {
if (!$user instanceof User) throw new Exception("…");
if (!$item instanceof Item) throw new Exception("…");
return
$user->money >= $item->price &&
$user->rating >= $item->requiredRating;
}
두 가지 조건을 확인합니다. 사용자에게 충분한 돈이 있으며 사용자의 평점이 충분합니다. isAllowed 메서드가 bool 만 반환 할 때 어떤 조건이 실패했는지 사용자가 알 수 있도록 오류 메시지를 표시하는 방법?
좋은 해결책. 또한 $ acl-> getErrors() 메소드와 같은 것을 만들 수 있습니다. –
@llya Golota 내 솔루션이 마음에 든다면 마킹하여 승인하십시오. –
부작용이 있습니까? –