/** * {@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); }
/** * 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)); } }