This processes changes on an ACE related property (classFieldAces, or objectFieldAces).
string $name:
array $changes:
void
private function updateFieldAceProperty($name, array $changes) {
$sids = new \SplObjectStorage();
$classIds = new \SplObjectStorage();
$currentIds = array();
foreach ($changes[1] as $field => $new) {
for ($i = 0, $c = count($new); $i < $c; $i++) {
$ace = $new[$i];
if (null === $ace
->getId()) {
if ($sids
->contains($ace
->getSecurityIdentity())) {
$sid = $sids
->offsetGet($ace
->getSecurityIdentity());
}
else {
$sid = $this
->createOrRetrieveSecurityIdentityId($ace
->getSecurityIdentity());
}
$oid = $ace
->getAcl()
->getObjectIdentity();
if ($classIds
->contains($oid)) {
$classId = $classIds
->offsetGet($oid);
}
else {
$classId = $this
->createOrRetrieveClassId($oid
->getType());
}
$objectIdentityId = $name === 'classFieldAces' ? null : $ace
->getAcl()
->getId();
$this->connection
->executeQuery($this
->getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $i, $sid, $ace
->getStrategy(), $ace
->getMask(), $ace
->isGranting(), $ace
->isAuditSuccess(), $ace
->isAuditFailure()));
$aceId = $this->connection
->executeQuery($this
->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, $field, $i))
->fetchColumn();
$this->loadedAces[$aceId] = $ace;
$aceIdProperty = new \ReflectionProperty('Symfony\\Component\\Security\\Acl\\Domain\\Entry', 'id');
$aceIdProperty
->setAccessible(true);
$aceIdProperty
->setValue($ace, intval($aceId));
}
else {
$currentIds[$ace
->getId()] = true;
}
}
}
foreach ($changes[0] as $old) {
for ($i = 0, $c = count($old); $i < $c; $i++) {
$ace = $old[$i];
if (!isset($currentIds[$ace
->getId()])) {
$this->connection
->executeQuery($this
->getDeleteAccessControlEntrySql($ace
->getId()));
unset($this->loadedAces[$ace
->getId()]);
}
}
}
}