我在sonata admin中更改文档的父级有问题。
我的文档有这样的属性:
/**
* @PHPCRODM\Children(filter="teaserimage*", cascade="persist")
* @var Image[]
*/
protected $teaserImages;
....
/**
* @Validation\PhpcrImage(maxWidth="1500", maxHeight="844", minWidth="600", minHeight="338", minRatio="1.77", maxRatio="1.78", nullable=false)
*
* @return Image|null
*/
public function getTeaserImage()
{
return $this->getLocalizedImage($this->teaserImages, 'teaserimage');
}
/**
* @param Image $image
*/
public function setTeaserImage($image)
{
$this->teaserImages->add(
self::setupImage($image, $this->getLocalizedImageNodeName('teaserimage'), $this->getTeaserImage())
);
}
当我试图更改任何文章文档的父级时,我得到了错误,如
The server returned a "500 Internal Server Error".
The Id is immutable (/cms/content/blog/blog-post-for-12th-october/teaserimage_de.jpg !== /cms/content/blog/blog-post-for-12th-october). Please use DocumentManager::move to move the document: blog post for 12th October (/cms/content/blog/blog-post-for-12th-october)
虽然发生此错误,但我的文档已移至所有子文档的正确位置。
这就是我的文档的样子 https://gist.github.com/milosnovi/a83f400c8ff06b4de6dd96e1f149a8dd
答案 0 :(得分:0)
检查preUpdated,prePersists方法。当更改是父更改时,不应在这些方法中刷新对象。