src/wcmf/lib/persistence/impl/DefaultTransaction.php
protected function processInserts() {
    $insertedOids = [];
    $pendingInserts = [];
    $insertOids = array_keys($this->newObjects);
    while (sizeof($insertOids) > 0) {
      $key = array_shift($insertOids);
      if (self::$isDebugEnabled) {
        self::$logger->debug("Process insert on object: ".$key);
      }
      $object = $this->newObjects[$key];
      // postpone insert, if the object has required objects that are
      // not persisted yet
      $canInsert = true;
      $requiredObjects = $object->getIndispensableObjects();
      foreach ($requiredObjects as $requiredObject) {
        if ($requiredObject->getState() == PersistentObject::STATE_NEW) {
          if (self::$isDebugEnabled) {
            self::$logger->debug("Postpone insert of object: ".$key.". Required objects are not saved yet.");
          }
          $pendingInserts[] = $object;
          $canInsert = false;
          break;
        }
      }
      if ($canInsert) {
        $oldOid = $object->getOID();
        $object->getMapper()->save($object);
        $insertedOids[$oldOid->__toString()] = $object->getOID()->__toString();
      }
      unset($this->newObjects[$key]);
      $insertOids = array_keys($this->newObjects);
      unset($this->observedObjects[$key]);
      $this->observedObjects[$object->getOID()->__toString()] = $object;
    }
    // re-add pending inserts
    foreach ($pendingInserts as $object) {
      $key = $object->getOID()->__toString();
      $this->newObjects[$key] = $object;
    }
    return $insertedOids;
  }
protected function processInserts() {
    $insertedOids = [];
    $pendingInserts = [];
    $insertOids = array_keys($this->newObjects);
    while (sizeof($insertOids) > 0) {
      $key = array_shift($insertOids);
      if (self::$isDebugEnabled) {
        self::$logger->debug("Process insert on object: ".$key);
      }
      $object = $this->newObjects[$key];
      // postpone insert, if the object has required objects that are
      // not persisted yet
      $canInsert = true;
      $requiredObjects = $object->getIndispensableObjects();
      foreach ($requiredObjects as $requiredObject) {
        if ($requiredObject->getState() == PersistentObject::STATE_NEW) {
          if (self::$isDebugEnabled) {
            self::$logger->debug("Postpone insert of object: ".$key.". Required objects are not saved yet.");
          }
          $pendingInserts[] = $object;
          $canInsert = false;
          break;
        }
      }
      if ($canInsert) {
        $oldOid = $object->getOID();
        $object->getMapper()->save($object);
        $insertedOids[$oldOid->__toString()] = $object->getOID()->__toString();
      }
      unset($this->newObjects[$key]);
      $insertOids = array_keys($this->newObjects);
      unset($this->observedObjects[$key]);
      $this->observedObjects[$object->getOID()->__toString()] = $object;
    }
    // re-add pending inserts
    foreach ($pendingInserts as $object) {
      $key = $object->getOID()->__toString();
      $this->newObjects[$key] = $object;
    }
    return $insertedOids;
  }
protected function processInserts ( ) { $ insertedOids = [ ] ; $ pendingInserts = [ ] ; $ insertOids = array_keys ( $ this -> newObjects ) ; while ( sizeof ( $ insertOids ) > 0 ) { $ key = array_shift ( $ insertOids ) ; if ( self :: $ isDebugEnabled ) { self :: $ logger -> debug ( "Process insert on object: " . $ key ) ; } $ object = $ this -> newObjects [ $ key ] ; // postpone insert, if the object has required objects that are // not persisted yet $ canInsert = true ; $ requiredObjects = $ object -> getIndispensableObjects ( ) ; foreach ( $ requiredObjects as $ requiredObject ) { if ( $ requiredObject -> getState ( ) == PersistentObject :: STATE_NEW ) { if ( self :: $ isDebugEnabled ) { self :: $ logger -> debug ( "Postpone insert of object: " . $ key . ". Required objects are not saved yet." ) ; } $ pendingInserts [ ] = $ object ; $ canInsert = false ; break ; } } if ( $ canInsert ) { $ oldOid = $ object -> getOID ( ) ; $ object -> getMapper ( ) -> save ( $ object ) ; $ insertedOids [ $ oldOid -> __toString ( ) ] = $ object -> getOID ( ) -> __toString ( ) ; } unset ( $ this -> newObjects [ $ key ] ) ; $ insertOids = array_keys ( $ this -> newObjects ) ; unset ( $ this -> observedObjects [ $ key ] ) ; $ this -> observedObjects [ $ object -> getOID ( ) -> __toString ( ) ] = $ object ; } // re-add pending inserts foreach ( $ pendingInserts as $ object ) { $ key = $ object -> getOID ( ) -> __toString ( ) ; $ this -> newObjects [ $ key ] = $ object ; } return $ insertedOids ; }
Process the new objects queue
@return Map of oids of inserted objects (key: oid string before commit, value: oid string after commit)
Process the new objects queue