本文整理汇总了PHP中Symfony\Component\Security\Acl\Model\AclInterface::getObjectIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP AclInterface::getObjectIdentity方法的具体用法?PHP AclInterface::getObjectIdentity怎么用?PHP AclInterface::getObjectIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Acl\Model\AclInterface
的用法示例。
在下文中一共展示了AclInterface::getObjectIdentity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: putInCache
/**
* {@inheritdoc}
*/
public function putInCache(AclInterface $acl)
{
if (null === $acl->getId()) {
throw new \InvalidArgumentException('Transient ACLs cannot be cached.');
}
$parentAcl = $acl->getParentAcl();
if (null !== $parentAcl) {
$this->putInCache($parentAcl);
}
$key = $this->createKeyFromIdentity($acl->getObjectIdentity());
$this->cache->save($key, serialize($acl));
$this->cache->save($acl->getId(), $key);
}
示例2: isAceApplicable
/**
* Determines whether the ACE is applicable to the given permission/security identity combination.
*
* Strategy ALL:
* The ACE will be considered applicable when all the turned-on bits in the
* required mask are also turned-on in the ACE mask.
*
* Strategy ANY:
* The ACE will be considered applicable when any of the turned-on bits in
* the required mask is also turned-on the in the ACE mask.
*
* Strategy EQUAL:
* The ACE will be considered applicable when the bitmasks are equal.
*
* @param integer $requiredMask
* @param EntryInterface $ace
* @param AclInterface $acl
* @throws \RuntimeException if the ACE strategy is not supported
* @return bool
*/
protected function isAceApplicable($requiredMask, EntryInterface $ace, AclInterface $acl)
{
$extension = $this->getContext()->getAclExtension();
$aceMask = $ace->getMask();
if ($acl->getObjectIdentity()->getType() === ObjectIdentityFactory::ROOT_IDENTITY_TYPE) {
if ($acl->getObjectIdentity()->getIdentifier() !== $extension->getExtensionKey()) {
return false;
}
$aceMask = $extension->adaptRootMask($aceMask, $this->getContext()->getObject());
}
if ($extension->getServiceBits($requiredMask) !== $extension->getServiceBits($aceMask)) {
return false;
}
$requiredMask = $extension->removeServiceBits($requiredMask);
$aceMask = $extension->removeServiceBits($aceMask);
$strategy = $ace->getStrategy();
switch ($strategy) {
case self::ALL:
return $requiredMask === ($aceMask & $requiredMask);
case self::ANY:
return 0 !== ($aceMask & $requiredMask);
case self::EQUAL:
return $requiredMask === $aceMask;
default:
throw new \RuntimeException(sprintf('The strategy "%s" is not supported.', $strategy));
}
}