private function Controller::updateAceProperty

This processes changes on an ACE related property (classAces, or objectAces).

Parameters

string $name:

array $changes:

Return value

void

File

drupal/core/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php, line 221

Class

Controller
@Route("/someprefix") @author Johannes M. Schmitt <schmittjoh@gmail.com>

Namespace

Doctrine\Tests\Common\Annotations\Fixtures

Code

private function updateAceProperty($name, array $changes) {
  list($old, $new) = $changes;
  $sids = new \SplObjectStorage();
  $classIds = new \SplObjectStorage();
  $currentIds = array();
  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 === 'classAces' ? null : $ace
        ->getAcl()
        ->getId();
      $this->connection
        ->executeQuery($this
        ->getInsertAccessControlEntrySql($classId, $objectIdentityId, null, $i, $sid, $ace
        ->getStrategy(), $ace
        ->getMask(), $ace
        ->isGranting(), $ace
        ->isAuditSuccess(), $ace
        ->isAuditFailure()));
      $aceId = $this->connection
        ->executeQuery($this
        ->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, null, $i))
        ->fetchColumn();
      $this->loadedAces[$aceId] = $ace;
      $aceIdProperty = new \ReflectionProperty($ace, 'id');
      $aceIdProperty
        ->setAccessible(true);
      $aceIdProperty
        ->setValue($ace, intval($aceId));
    }
    else {
      $currentIds[$ace
        ->getId()] = true;
    }
  }
  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()]);
    }
  }
}