I'm facing this weird problem with Sonata media bundle.
Basically, I have an exercise that can have many pictures.
My mapping of Exercice (it's French language) is :
/**
* @ORM\OneToMany(targetEntity="Application\Sonata\MediaBundle\Entity\Media", mappedBy="exercice")
*/
private $medias;
Then I go to Application/Sonara/MediaBundle/Entity/Media.php and add a field $exercice:
namespace Application\Sonata\MediaBundle\Entity;
use Sonata\MediaBundle\Entity\BaseMedia as BaseMedia;
use Doctrine\ORM\Mapping as ORM;
class Media extends BaseMedia
{
/**
* @var integer $id
*/
protected $id;
/**
* @var
* @ORM\ManyToOne(targetEntity="Acme\AcmeBundle\Entity\Exercice", inversedBy="medias")
*/
private $exercice;
Weird things that happen :
- When I run :
php app/console doctrine:generate:entities Application\Sonata\MediaBundle:Media
I don't see any setter or getter for Exercice inside Media entity.- I get this error in profiler :
The association Acme\AcmeBundle\Entity\Exercice#medias refers to the owning side field Application\Sonata\MediaBundle\Entity\Media#exercice which does not exist.
The relevant part of config :
orm: auto_generate_proxy_classes: "%kernel.debug%" auto_mapping: true mappings: ApplicationSonataMediaBundle: ~ SonataMediaBundle: ~
What am I doing wrong ?
Thanks