getDocumentById() public méthode

Tries to find a document with the given id in the identity map of this UnitOfWork.
public getDocumentById ( string $id ) : object | false
$id string The document id to look for.
Résultat object | false Returns the document with the specified id if it exists in this UnitOfWork, FALSE otherwise.
 /**
  * {@inheritDoc}
  */
 public function findTranslation($className, $id, $locale, $fallback = true)
 {
     try {
         if (UUIDHelper::isUUID($id)) {
             try {
                 $id = $this->session->getNodeByIdentifier($id)->getPath();
             } catch (ItemNotFoundException $e) {
                 return null;
             }
         } elseif (strpos($id, '/') !== 0) {
             $id = '/' . $id;
         }
         $document = $this->unitOfWork->getDocumentById($id);
         if ($document) {
             $this->unitOfWork->validateClassName($document, $className);
             $class = $this->getClassMetadata(get_class($document));
             $this->unitOfWork->doLoadTranslation($document, $class, $locale, $fallback);
             return $document;
         }
         $node = $this->session->getNode($id);
     } catch (PathNotFoundException $e) {
         return null;
     }
     $hints = array('locale' => $locale, 'fallback' => $fallback);
     return $this->unitOfWork->getOrCreateDocument($className, $node, $hints);
 }
 /**
  * Gets a reference to the document identified by the given type and identifier
  * without actually loading it.
  *
  * If partial objects are allowed, this method will return a partial object that only
  * has its identifier populated. Otherwise a proxy is returned that automatically
  * loads itself on first access.
  *
  * @param string $documentName
  * @param string|object $id
  * @return mixed|object The document reference.
  */
 public function getReference($documentName, $id)
 {
     $class = $this->metadataFactory->getMetadataFor($documentName);
     // Check identity map first, if its already in there just return it.
     $document = $this->unitOfWork->getDocumentById($id);
     if ($document) {
         return $document;
     }
     $document = $this->proxyFactory->getProxy($class->name, $id);
     $this->unitOfWork->registerDocument($document, $id);
     return $document;
 }
 public function testGetDocumentById()
 {
     $user1 = $this->uow->getOrCreateDocument($this->type, $this->createNode('/somepath', 'foo'));
     $user2 = $this->uow->getDocumentById('/somepath', $this->type);
     $this->assertSame($user1, $user2);
 }