本文整理匯總了PHP中Magento\Backend\Model\Auth\Session::isAllowed方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::isAllowed方法的具體用法?PHP Session::isAllowed怎麽用?PHP Session::isAllowed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Backend\Model\Auth\Session
的用法示例。
在下文中一共展示了Session::isAllowed方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isAllowed
/**
* {@inheritdoc}
*/
public function isAllowed($resource, $privilege = null)
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'isAllowed');
if (!$pluginInfo) {
return parent::isAllowed($resource, $privilege);
} else {
return $this->___callPlugins('isAllowed', func_get_args(), $pluginInfo);
}
}
示例2: testIsAllowed
/**
* @dataProvider isAllowedDataProvider
* @param bool $isUserDefined
* @param bool $isAclDefined
* @param bool $isAllowed
* @param true $expectedResult
*/
public function testIsAllowed($isUserDefined, $isAclDefined, $isAllowed, $expectedResult)
{
$userAclRole = 'userAclRole';
if ($isAclDefined) {
$aclMock = $this->getMockBuilder('Magento\\Framework\\Acl')->disableOriginalConstructor()->getMock();
$this->storage->expects($this->any())->method('getAcl')->willReturn($aclMock);
}
if ($isUserDefined) {
$userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->getMock();
$this->storage->expects($this->once())->method('getUser')->willReturn($userMock);
}
if ($isAclDefined && $isUserDefined) {
$userMock->expects($this->any())->method('getAclRole')->willReturn($userAclRole);
$aclMock->expects($this->once())->method('isAllowed')->with($userAclRole)->willReturn($isAllowed);
}
$this->assertEquals($expectedResult, $this->session->isAllowed('resource'));
}
示例3: canAccessLoginAs
/**
* 'true' - if admin user has right to use 'Login As' feature.
* @return bool
*/
public static function canAccessLoginAs()
{
return filter_var($this->_modelAuthSession->isAllowed('customer/prxgt_lgas_access'), FILTER_VALIDATE_BOOLEAN);
}