2

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.

Error

And following Error

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

enter image description here

I just followed the official documentation from here.

Anybody can help regarding it?

Yusuf Ibrahim
  • 1,591
  • 5
  • 21
  • 46
  • As far as I understand Flex *should* create `App\Entity\SonataMediaMedia` instead of us having to use easy extends to generate entities in the `App\Application` namespace but this seems not to be happening. Not sure what to do about it though... – Bananaapple Jul 18 '19 at 14:44
  • Yusuf did you find a solution for the first error? '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.' – GAV Sep 09 '19 at 16:33

1 Answers1

1

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.

Bananaapple
  • 2,984
  • 2
  • 25
  • 38