【问题标题】:Sonata Doctrine Phpcr Admin Bundle: Change parent of nodeSonata Doctrine Phpcr Admin Bundle:更改节点的父级
【发布时间】:2017-03-15 14:55:24
【问题描述】:

我在奏鸣曲管理员中更改文档的父级时遇到问题。

我的文档有这样的属性:

 /**
 * @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

【问题讨论】:

  • 您是否尝试过使用文档管理器的 move() 功能?当你在 gui 中移动时,你能尝试找出奏鸣曲管理员在做什么,它是否使用了移动功能以外的其他东西?

标签: sonata-admin symfony-sonata doctrine-odm symfony-cmf doctrine-phpcr


【解决方案1】:

检查您的 preUpdated、prePersists 方法。当更改是父更改时,您不应该在这些方法中刷新对象。

【讨论】:

    猜你喜欢
    • 2017-05-18
    • 1970-01-01
    • 1970-01-01
    • 2016-09-03
    • 2012-09-03
    • 1970-01-01
    • 2016-04-20
    • 1970-01-01
    • 2013-03-06
    相关资源
    最近更新 更多