Doctrine\ODM\MongoDB\UnitOfWork::clear PHP Method

clear() public method

Clears the UnitOfWork.
public clear ( string | null $documentName = null )
$documentName string | null if given, only documents of this type will get detached.
    public function clear($documentName = null)
    {
        if ($documentName === null) {
            $this->identityMap = $this->documentIdentifiers = $this->originalDocumentData = $this->documentChangeSets = $this->documentStates = $this->scheduledForDirtyCheck = $this->documentInsertions = $this->documentUpserts = $this->documentUpdates = $this->documentDeletions = $this->collectionUpdates = $this->collectionDeletions = $this->parentAssociations = $this->embeddedDocumentsRegistry = $this->orphanRemovals = $this->hasScheduledCollections = array();
        } else {
            $visited = array();
            foreach ($this->identityMap as $className => $documents) {
                if ($className === $documentName) {
                    foreach ($documents as $document) {
                        $this->doDetach($document, $visited);
                    }
                }
            }
        }
        if ($this->evm->hasListeners(Events::onClear)) {
            $this->evm->dispatchEvent(Events::onClear, new Event\OnClearEventArgs($this->dm, $documentName));
        }
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Clears the DocumentManager. All entities that are currently managed
  * by this DocumentManager become detached.
  *
  * @param string $documentName
  */
 public function clear($documentName = null)
 {
     if ($documentName === null) {
         $this->unitOfWork->clear();
     } else {
         //TODO
         throw new MongoDBException("DocumentManager#clear(\$documentName) not yet implemented.");
     }
 }
All Usage Examples Of Doctrine\ODM\MongoDB\UnitOfWork::clear
UnitOfWork