Doctrine\ODM\PHPCR\UnitOfWork::getDocumentById PHP Method

getDocumentById() public method

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.
return object | false Returns the document with the specified id if it exists in this UnitOfWork, FALSE otherwise.
    public function getDocumentById($id)
    {
        if (isset($this->identityMap[$id])) {
            return $this->identityMap[$id];
        }
        return false;
    }

Usage Example

Example #1
0
 /**
  * {@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);
 }
All Usage Examples Of Doctrine\ODM\PHPCR\UnitOfWork::getDocumentById
UnitOfWork