2

在安装 SonataNewsBundle 时出现以下错误。

Unable to register extension "Sonata\FormatterBundle\Extension\ControlFlowExtension" as it is already registered in . (which is being imported from "/home/yoesoff/Documents/projects/oblog/config/routes/sonata_admin.yaml"). Make sure there is a loader supporting the "sonata_admin" type.

错误

并跟随错误

The target-entity App\Entity\SonataMediaMedia cannot be found in 'App\Entity\SonataClassificationCollection#media'.

在此处输入图像描述

我只是从这里关注了官方文档。

有人可以帮忙吗?

4

1 回答 1

1

文档中缺少一个步骤 - 看起来我们需要手动添加一个额外的包来创建缺少的类:

composer require sonata-project/media-orm-pack

请注意,如果您正在使用sonata-project/classification-bundle,则需要App\Entity\SonataMediaMedia::$category像这样修复注释:

/**
 * ORM\ManyToOne(
 *     targetEntity="App\Entity\SonataClassificationCategory",
 *     cascade={"persist"}
 * )
 * ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="SET NULL")
 *
 * @var SonataClassificationCategory
 */
protected $category;

如果有帮助,据我了解,我们应该sonata:easy-extends:generate在使用 Symfony 4 / Flex 时跳过这些步骤。

Flex 配方应该在我们的App\Entity命名空间中创建类。

如果他们不这样做,则需要手动添加上述内容。

于 2019-07-18T15:05:26.923 回答