本文整理汇总了PHP中Doctrine\ODM\PHPCR\DocumentManager::getProxyFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::getProxyFactory方法的具体用法?PHP DocumentManager::getProxyFactory怎么用?PHP DocumentManager::getProxyFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\PHPCR\DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::getProxyFactory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createProxy
/**
* Create a proxy instance or return an existing document
*
* @param $targetId
* @param $className
*
* @return object
*/
private function createProxy($targetId, $className)
{
$document = $this->getDocumentById($targetId);
// check if referenced document already exists
if ($document) {
return $document;
}
$proxyDocument = $this->dm->getProxyFactory()->getProxy($className, $targetId);
// register the document under its own id
$this->registerDocument($proxyDocument, $targetId);
return $proxyDocument;
}
示例2: getOrCreateProxy
/**
* 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;
}