2017-09-06 20 views
0

我想清除我的節點樹用於測試目的,我不能刪除根節點的所有子節點。學說PHPCR:如何從根文件中刪除兒童?

<?php 
$dm = $this->getDocumentManager(); 
$rootDoc = $dm->find(null,'/'); 
/** @var AbstractDocument[] $children */ 
$children = $rootDoc->getChildren(); 
foreach ($children as $child) { 
    echo $child->getUuid()."\n"; 
    $dm->remove($child); 
} 
$dm->flush(); 

我得到下面的異常

Doctrine\ODM\PHPCR\PHPCRException: Cannot move/copy children by assignment as it would be ambiguous. Please use the DocumentManager::move() or PHPCR\Session::copy() operations for this: [..] 

根節點是一般的情況下,是AbstractDocument有家長ID策略。

回答

0

AbstractDocument中的@Nodename屬性丟失。因此可以創建節點,但不能刪除它們。

編輯:這沒有解決。如果@Nodename屬性存在,我必須設置一個,並且不能使用自動生成的功能。