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;
}
2つの条件を確認します。ユーザーには十分なお金があり、ユーザーの評価は十分です。 isAllowedメソッドがboolだけを返すときにどの条件が失敗したかをユーザーに知らせるエラーメッセージを表示するには?
良い解決策。また、$ acl-> getErrors()メソッドのようなものを作成できます。 –
@llya Golotaあなたが私のソリューションが好きなら、マーキングして受け入れてください。 –
副作用は問題ありませんか? –