本文整理匯總了PHP中JAccessRules::allow方法的典型用法代碼示例。如果您正苦於以下問題:PHP JAccessRules::allow方法的具體用法?PHP JAccessRules::allow怎麽用?PHP JAccessRules::allow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JAccessRules
的用法示例。
在下文中一共展示了JAccessRules::allow方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAllow
/**
* Tests the JAccessRules::allow method.
*
* @return void
*
* @since 11.1
*/
public function testAllow()
{
$array1 = array('edit' => array(-42 => 1), 'delete' => array(-42 => 0, 2 => 1));
$rules = new JAccessRules($array1);
// Explicit allow.
$this->assertTrue($rules->allow('edit', -42));
// Check string or int works.
$this->assertTrue($rules->allow('edit', '-42'));
// Implicit deny
$this->assertNull($rules->allow('edit', 999));
// Explicit deny
$this->assertFalse($rules->allow('delete', -42));
// This should be true, implicit deny does not win.
$this->assertTrue($rules->allow('edit', array(-42, 999)));
// This should be false, explicit deny wins.
$this->assertFalse($rules->allow('delete', array(-42, 2)));
// This should be null, the action doesn't exist.
$this->assertNull($rules->allow('unknown', array(-42, 2)));
}