Reputation: 1004
Situation
I am using Symfony (and MongoDB as DB) and want to integrate the Sonata Media Bundle in to the Sonata Admin bundle. Prior to adding the media bundle, everything was working great.
I followed the guide on the Sonata site and have appeared to setup the media admin bundle correctly; please see config below
config.yml
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: test_database
document_managers:
default:
mappings:
ApplicationSonataMediaBundle: ~
SonataMediaBundle: ~
auto_mapping: true
...
sonata_media:
# if you don't use default namespace configuration
#class:
# media: MyVendor\MediaBundle\Entity\Media
# gallery: MyVendor\MediaBundle\Entity\Gallery
# gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia
default_context: default
db_driver: doctrine_mongodb # or doctrine_mongodb, doctrine_phpcr
contexts:
default: # the default context is mandatory
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
formats:
small: { width: 100 , quality: 70}
big: { width: 500 , quality: 70}
Company.php Document class
namespace AppBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document
*/
class Company
{
/**
* @MongoDB\Id
*/
protected $id;
/**
* @MongoDB\String
*/
protected $title;
/**
* @MongoDB\String
*/
protected $slug;
/**
* @MongoDB\ReferenceMany(targetDocument="Application\Sonata\MediaBundle\Document\Media", mappedBy="image")
*/
protected $logo;
companyadmin.php
->add('logo', 'sonata_type_model_list', array(), array('link_parameters' => array('context' => 'default')))
Issue
Now, whenever I go in to the company admin interface, I'm greeted by the message "No document manager defined for class Doctrine\ODM\MongoDB\PersistentCollection"
I'm relatively new to Symfony and I don't really see what is going wrong. Please can you help give a poke in the right direction. If I remove the logo from admin, naturally it starts working again. Please help, really clueless here
Upvotes: 1
Views: 796
Reputation: 146
If you use: auto_mapping: true you don't need document manager default mappings, otherwise you have to add in your config file:
orm:
# auto_mapping: true
entity_managers:
default:
connection: default
# naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
ApplicationSonataUserBundle: ~
ApplicationSonataMediaBundle: ~
YourBundle: ~
Check in AppKernel.php for the ApplicationSonataMediaBundle() instance run the command:
run app/console doctrine:schema:update --force
Take a look to this question too:
How to define/pass the entity manager for sonata-admin
Upvotes: 0