本文整理汇总了PHP中AuthorizationPolicy::applies方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthorizationPolicy::applies方法的具体用法?PHP AuthorizationPolicy::applies怎么用?PHP AuthorizationPolicy::applies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthorizationPolicy
的用法示例。
在下文中一共展示了AuthorizationPolicy::applies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
/**
* @see HandlerValidator::isValid()
*/
function isValid()
{
// Delegate to the AuthorizationPolicy
if (!$this->_policy->applies()) {
return false;
}
if ($this->_policy->effect() == AUTHORIZATION_DENY) {
return false;
} else {
return true;
}
}
示例2: isValid
/**
* @see HandlerValidator::isValid()
*/
function isValid()
{
// Delegate to the AuthorizationPolicy
if (!$this->_policy->applies()) {
return false;
}
// Pass the authorized context to the police.
$this->_policy->setAuthorizedContext($this->handler->getAuthorizedContext());
if ($this->_policy->effect() == AUTHORIZATION_DENY) {
return false;
} else {
return true;
}
}
示例3: testAuthorizationPolicy
/**
* @covers AuthorizationPolicy
*/
public function testAuthorizationPolicy()
{
$policy = new AuthorizationPolicy('some message');
// Test advice.
self::assertTrue($policy->hasAdvice(AUTHORIZATION_ADVICE_DENY_MESSAGE));
self::assertFalse($policy->hasAdvice(AUTHORIZATION_ADVICE_CALL_ON_DENY));
self::assertEquals('some message', $policy->getAdvice(AUTHORIZATION_ADVICE_DENY_MESSAGE));
self::assertNull($policy->getAdvice(AUTHORIZATION_ADVICE_CALL_ON_DENY));
// Test authorized context objects.
self::assertFalse($policy->hasAuthorizedContextObject(ASSOC_TYPE_USER_GROUP));
$someContextObject = new DataObject();
$someContextObject->setData('test1', 'test1');
$policy->addAuthorizedContextObject(ASSOC_TYPE_USER_GROUP, $someContextObject);
self::assertTrue($policy->hasAuthorizedContextObject(ASSOC_TYPE_USER_GROUP));
self::assertEquals($someContextObject, $policy->getAuthorizedContextObject(ASSOC_TYPE_USER_GROUP));
self::assertEquals(array(ASSOC_TYPE_USER_GROUP => $someContextObject), $policy->getAuthorizedContext());
// Test authorized context.
$someOtherContextObject = new DataObject();
$someOtherContextObject->setData('test2', 'test2');
$authorizedContext = array(ASSOC_TYPE_USER_GROUP => $someOtherContextObject);
$policy->setAuthorizedContext($authorizedContext);
self::assertEquals($authorizedContext, $policy->getAuthorizedContext());
// Test default policies.
self::assertTrue($policy->applies());
self::assertEquals(AUTHORIZATION_DENY, $policy->effect());
}