本文整理汇总了PHP中Doctrine\ODM\PHPCR\DocumentManager::detach方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::detach方法的具体用法?PHP DocumentManager::detach怎么用?PHP DocumentManager::detach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\PHPCR\DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::detach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findVersionByName
/**
* @see DocumentManager::findVersionByName
*/
public function findVersionByName($className, $id, $versionName)
{
$versionManager = $this->session->getWorkspace()->getVersionManager();
try {
$history = $versionManager->getVersionHistory($id);
} catch (ItemNotFoundException $e) {
// there is no document with $id
return null;
} catch (UnsupportedRepositoryOperationException $e) {
throw new InvalidArgumentException("Document with id {$id} is not versionable", $e->getCode(), $e);
}
try {
$version = $history->getVersion($versionName);
$node = $version->getFrozenNode();
} catch (RepositoryException $e) {
throw new InvalidArgumentException("No version {$versionName} on document {$id}", $e->getCode(), $e);
}
$hints = array('versionName' => $versionName, 'ignoreHardReferenceNotFound' => true);
$frozenDocument = $this->getOrCreateDocument($className, $node, $hints);
$this->dm->detach($frozenDocument);
$oid = spl_object_hash($frozenDocument);
$this->documentHistory[$oid] = $history;
$this->documentVersion[$oid] = $version;
// Set the annotations
$metadata = $this->dm->getClassMetadata(get_class($frozenDocument));
if ($metadata->versionNameField) {
$metadata->reflFields[$metadata->versionNameField]->setValue($frozenDocument, $versionName);
}
if ($metadata->versionCreatedField) {
$metadata->reflFields[$metadata->versionCreatedField]->setValue($frozenDocument, $version->getCreated());
}
return $frozenDocument;
}
示例2: testDetachWithChildren
public function testDetachWithChildren()
{
$parent = $this->dm->find(null, '/functional');
$this->dm->detach($parent);
}