简体   繁体   中英

Symfony 4 and Sonata News Bundle Error during Intallation

I got the following error during installing 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.

错误

And following Error

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

在此处输入图片说明

I just followed the official documentation from here .

Anybody can help regarding it?

There's a step missing in the documentation - looks like we manually need to add an extra package that creates the missing classes:

composer require sonata-project/media-orm-pack

Note that if you are using sonata-project/classification-bundle , you need to fix annotations for App\\Entity\\SonataMediaMedia::$category like so:

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

If it helps, as far as I understand we should be skipping the sonata:easy-extends:generate steps when using Symfony 4 / Flex.

The Flex recipes should be creating classes in our App\\Entity namespace.

If they do not it will be something along the lines of the above where things need added manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM