/** * Get the existing document or proxy for this id of this class, or create * a new one. * * @param string $targetId * @param string $className * @param string $locale * * @return object */ public function getOrCreateProxy($targetId, $className, $locale = null) { $document = $this->getDocumentById($targetId); // check if referenced document already exists if ($document) { $metadata = $this->dm->getClassMetadata($className); if ($locale && $locale !== $this->getCurrentLocale($document, $metadata)) { $this->doLoadTranslation($document, $metadata, $locale, true); } return $document; } $metadata = $this->dm->getClassMetadata($className); $proxyDocument = $this->dm->getProxyFactory()->getProxy($className, array($metadata->identifier => $targetId)); // register the document under its own id $this->registerDocument($proxyDocument, $targetId); if ($locale) { $this->setLocale($proxyDocument, $this->dm->getClassMetadata($className), $locale); } return $proxyDocument; }
/** * {@inheritDoc} */ public function getProxyFactory() { return $this->wrapped->getProxyFactory(); }