Próbuję dodać pojedynczy obrazek dla projektu w sonata media bundle.
Ale podczas dodawania występuje taki błąd:
There is no main category related to context: product

Plik product.php:
  1. //private $filename;
  2. /**
  3.   * @var \Application\Sonata\MediaBundle\Entity\Media
  4.   * @ORM\ManyToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"}, fetch="LAZY")
  5.   */
  6. protected $media;
  7.  
  8. /**
  9.   * @param MediaInterface $media
  10.   */
  11. public function setMedia( $media)
  12. {
  13. $this->media = $media;
  14. }
  15.  
  16. /**
  17.   * @return MediaInterface
  18.   */
  19. public function getMedia()
  20. {
  21. return $this->media;
  22. }


plik productAdmin:

  1. ->add('media', 'sonata_media_type', array(
  2. 'provider' => 'sonata.media.provider.image',
  3. 'context' => 'product'
  4. ))


plik config.yml:

  1. sonata_media:
  2. # if you don't use default namespace configuration
  3. #class:
  4. # media: MyVendor\MediaBundle\Entity\Media
  5. # gallery: MyVendor\MediaBundle\Entity\Gallery
  6. # gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia
  7. db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here
  8. default_context: default # you need to set a context
  9. contexts:
  10. default: # the default context is mandatory
  11. providers:
  12. - sonata.media.provider.image
  13.  
  14.  
  15. formats:
  16. small: { width: 100 , quality: 100}
  17. big: { width: 500 , quality: 100}
  18.  
  19. product:
  20. providers:
  21. - sonata.media.provider.image
  22.  
  23. formats:
  24. preview: { width: 100, quality: 100}
  25. small: { width: 200, quality: 100}
  26. large: { width: 600, quality: 100}
  27. cdn:
  28. server:
  29. path: /dzierganie/web/uploads/media # http://media.sonata-project.org/


Galeria dla contextu default działa dobrze, tylko problem występuje chyba tylko przy dodaniu nowego contextu.
Wyczytałem w googlach że to ma związek z sonata classification bundle, ale nie za bardzo wiem co mam tam ustawić.
może coś jeszcze trzeba ustawić, zrobiłem to welug dokumentacji.
Ktoś wie jak rozwiązać ten problem?