本文整理汇总了PHP中Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration::hasPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestConfiguration::hasPermission方法的具体用法?PHP RequestConfiguration::hasPermission怎么用?PHP RequestConfiguration::hasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration
的用法示例。
在下文中一共展示了RequestConfiguration::hasPermission方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isGranted
/**
* @param RequestConfiguration $requestConfiguration
* @param string $permission
*
* @return bool
*/
public function isGranted(RequestConfiguration $requestConfiguration, $permission)
{
if (!$requestConfiguration->hasPermission()) {
return true;
}
return $this->rbacAuthorizationChecker->isGranted($permission);
}
示例2:
function it_uses_rbac_authorization_checker(RequestConfiguration $requestConfiguration, RbacAuthorizationCheckerInterface $rbacAuthorizationChecker)
{
$requestConfiguration->hasPermission()->willReturn(true);
$requestConfiguration->getPermission('sylius.product.foo')->willReturn('sylius.product.foo');
$rbacAuthorizationChecker->isGranted('sylius.product.foo')->willReturn(false);
$this->isGranted($requestConfiguration, 'sylius.product.foo')->shouldReturn(false);
$rbacAuthorizationChecker->isGranted('sylius.product.foo')->willReturn(true);
$this->isGranted($requestConfiguration, 'sylius.product.foo')->shouldReturn(true);
}
示例3: get
/**
* {@inheritdoc}
*/
public function get(RequestConfiguration $requestConfiguration, RepositoryInterface $repository)
{
if ($requestConfiguration->hasPermission() && $this->requireOwnerCheck($vars = $requestConfiguration->getVars())) {
$owner = $this->currentIdentityProvider->getIdentity();
$ownerField = is_bool($vars['acl_owner']) ? ResourceOwnerFilter::FIELD : $vars['acl_owner'];
// using in grid param
$requestConfiguration->getRequest()->query->set(ResourceOwnerFilter::TYPE, $owner);
$criteria = $requestConfiguration->getCriteria();
$criteria[$ownerField] = $owner;
$requestConfiguration->getParameters()->set('criteria', $criteria);
}
return $this->decoratedResolver->get($requestConfiguration, $repository);
}
示例4: isGrantedOr403
/**
* @param RequestConfiguration $configuration
* @param string $permission
*
* @throws AccessDeniedException
*/
protected function isGrantedOr403(RequestConfiguration $configuration, $permission)
{
if (!$configuration->hasPermission()) {
return;
}
$permission = $configuration->getPermission($permission);
if (!$this->authorizationChecker->isGranted($configuration, $permission)) {
throw new AccessDeniedException();
}
}