Doctrine\ODM\CouchDB\UnitOfWork::registerManaged PHP Method

registerManaged() public method

public registerManaged ( $document, $identifier, $revision )
    public function registerManaged($document, $identifier, $revision)
    {
        $oid = spl_object_hash($document);
        $this->documentState[$oid] = self::STATE_MANAGED;
        $this->documentIdentifiers[$oid] = (string) $identifier;
        $this->documentRevisions[$oid] = $revision;
        $this->identityMap[$identifier] = $document;
    }

Usage Example

Beispiel #1
0
 /**
  * Gets a reference to the entity identified by the given type and identifier
  * without actually loading it, if the entity is not yet loaded.
  *
  * @param string $documentName The name of the entity type.
  * @param mixed $identifier The entity identifier.
  * @return object The entity reference.
  */
 public function getReference($documentName, $identifier)
 {
     $class = $this->metadataFactory->getMetadataFor(ltrim($documentName, '\\'));
     // Check identity map first, if its already in there just return it.
     if ($document = $this->unitOfWork->tryGetById($identifier)) {
         return $document;
     }
     $document = $this->proxyFactory->getProxy($class->name, $identifier);
     $this->unitOfWork->registerManaged($document, $identifier, null);
     return $document;
 }