Symfony Sonata Media Bundle add images/videos to a user

后端 未结 2 1496
青春惊慌失措
青春惊慌失措 2021-02-06 07:45

I am trying to integrate Sonata Media Bundle in my project. The problem is, that i don\'t understand how the bundle works.

It has generated a Media, Gallery and GalleryH

2条回答
  •  死守一世寂寞
    2021-02-06 08:36

    From the documentation:

    "Note

    The command will generate domain objects in an Application namespace. So you can point entities’ associations to a global and common namespace. This will make Entities sharing very easier as your models will allow to point to a global namespace. For instance the media will be Application\Sonata\MediaBundle\Entity\Media." http://sonata-project.org/bundles/media/2-2/doc/reference/installation.html

    Pretty much what you get whenever you use the easy-extands bundle.

    You use them just like any entity, just from a different namespace to your exisitng Entities.

    As to using them in another form type, just embed the media form type in your user form type: http://sonata-project.org/bundles/media/2-2/doc/reference/form.html

    To add the fields to another entity you just add the property with getters and setters and (we always use doctrine annotations not yaml) add the annotation for the media entity as the target entity with the column name for the type of relationship (1:1,1:M,M:M, etc) in the usual symfony way.

提交回复
热议问题