/** * Returns a reference to an entity. It will be lazily and transparently * loaded if anything other than the identifier is touched. * * @param $rid * * @return Proxy */ public function getReference($rid) { $oclass = $this->clusterMap->identifyClass($rid); $md = $this->metadataFactory->getMetadataForOClass($oclass); if ($document = $this->uow->tryGetById($rid, $md)) { return $document; } $document = $this->proxyFactory->getProxy($md->name, [$md->getRidPropertyName() => $rid]); $this->uow->registerManaged($document, $rid, []); return $document; }
/** * @param $rid * @param string $fetchPlan * * @return mixed|null * @throws OrientDBException */ public function findWithPlan($rid, $fetchPlan = '*:0') { if (empty($rid)) { return null; } // try identity map first if (!($document = $this->uow->tryGetById($rid, $this->metadata))) { $document = $this->getDocumentPersister()->load($rid, $fetchPlan); } if ($document && !$this->contains($document)) { throw new OrientDBException("You are asking to find record {$rid} through the repository {$this->getClassName()} " . "but the document belongs to another repository (" . get_class($document) . ")"); } return $document; }