Пример #1
0
 /**
  * Flushes all changes to ACLs that have been queued up to now to the database.
  * This synchronizes the in-memory state of managed ACLs with the database.
  */
 public function flush()
 {
     $this->validateAclEnabled();
     $transactionStarted = false;
     try {
         foreach ($this->items as $item) {
             if ($item->getState() === BatchItem::STATE_NONE) {
                 continue;
             }
             if (!$transactionStarted) {
                 $this->aclProvider->beginTransaction();
                 $transactionStarted = true;
             }
             switch ($item->getState()) {
                 case BatchItem::STATE_CREATE:
                     $acl = $this->aclProvider->createAcl($item->getOid());
                     $hasChanges = false;
                     foreach ($item->getAces() as $ace) {
                         $hasChanges |= $this->aceProvider->setPermission($acl, $this->extensionSelector->select($item->getOid()), $ace->isReplace(), $ace->getType(), $ace->getField(), $ace->getSecurityIdentity(), $ace->isGranting(), $ace->getMask(), $ace->getStrategy());
                     }
                     if ($hasChanges) {
                         $this->aclProvider->updateAcl($acl);
                     }
                     break;
                 case BatchItem::STATE_UPDATE:
                     $this->aclProvider->updateAcl($item->getAcl());
                     break;
                 case BatchItem::STATE_DELETE:
                     $this->aclProvider->deleteAcl($item->getOid());
                     break;
             }
         }
         if ($transactionStarted) {
             $this->aclProvider->commit();
             $this->items = array();
         }
     } catch (\Exception $ex) {
         try {
             if ($transactionStarted) {
                 $this->aclProvider->rollBack();
             }
         } catch (\Exception $rollBackEx) {
             // ignore any exceptions during the rolling back operation
         }
         throw $ex;
     }
 }
Пример #2
0
 public function testRollBack()
 {
     $this->connection->expects($this->once())->method('rollBack');
     $this->provider->rollBack();
 }