SonataNewsBundle config is not accepting given classes

38 views Asked by At

So I have the following config part from SonataNewsBundle (whom I transfered to /src to make it work in compliance with symfony 6.2):

db_driver: doctrine_orm
class:
    post: App\Entity\Post
    comment: App\Entity\Comment
    media: Sonata\MediaBundle\Entity\SonataMediaMedia
    user: App\Entity\User
    tag: App\Entity\SonataClassificationTag
    collection: App\Entity\SonataClassificationCollection

The problem is that it gives me this error if I try to type any symfony command (like bin/console doctrine:schema:update --force):

Class "App\Entity\SonataMediaMedia" sub class of "Sonata\MediaBundle\Entity\BaseMedia" is not a valid entity or mapped super class.

It's worth mentioning that the Media entity was working fine before adding SonataMediaBundle into src and making corresponding changes (like changing namespaces, resolving deprecated methods, adding DependencyInjection folder...).

This is the code for the media entity:

<?php
// src/Entity/SonataMediaMedia.php
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Sonata\MediaBundle\Entity\BaseMedia;

#[ORM\Entity]
#[ORM\Table(name: 'media__media')]
class SonataMediaMedia extends BaseMedia
{
    #[ORM\Id]
    #[ORM\Column(type: Types::INTEGER)]
    #[ORM\GeneratedValue]
    protected ?int $id = null;

    public function getId(): ?int
    {
        return $this->id;
    }
}

At the same time there was this error when I try to log into the registered account on the application web server that might be helpful in tracking the problem:

Uncaught PHP Exception RuntimeException: "Unable to find the mapping information for the class App\Entity\User. Please check the auto_mapping option (http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview) or add the bundle to the mappings section in the doctrine configuration." at C:\Users\masto\webapp\vendor\sonata-project\doctrine-extensions\src\Model\BaseManager.php line 129 {"exception":"[object] (RuntimeException(code: 0): Unable to find the mapping information for the class App\Entity\User. Please check the auto_mapping option (http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview) or add the bundle to the mappings section in the doctrine configuration. at C:\Users\masto\webapp\vendor\sonata-project\doctrine-extensions\src\Model\BaseManager.php:129)"}

0

There are 0 answers