...
public function registerBundles()
{
$bundles = array(
...
new MandarinMedien\MMMediaBundle\MMMediaBundle(),
...
);
....
}
...
...
imports:
- { resource: '@MMMediaBundle/Resources/config/config.yml' }
...
...
mm_media:
resource: "@MMMediaBundle/Resources/config/routing.yml"
prefix: /mmmedia
...
...
shell: mkdir PROJECT_ROOT/web/media
...
You need to use the MediaSortable Entity of this bundle to have sortable Media. For a collection of media, use an unidirectional manyToMany-association and for single media an unidirectional oneToOne. To avoid garbage in your database, make sure to set the orphanRemoval flag.
...
oneToOne:
titleImage:
targetEntity: MandarinMedien\MMMediaBundle\Entity\MediaSortable
cascade:
- persist
- remove
...
...
manyToMany:
medias:
targetEntity: MandarinMedien\MMMediaBundle\Entity\MediaSortable
orderBy: { 'position': 'ASC' }
joinColumn:
name: media_sortable_id
referencedColumnName: id
cascade:
- persist
- remove
orphanRemoval: true
...
To make the MMMediaBundle-UploadWidget work properly you need to add the necessary CSS and the JS files. Your can just copy this part below or add @mmmedia_assets_css and @mmmedia_assets_js into your asset calls.
...
{% stylesheets '@mmmedia_assets_css' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% javascripts '@mmmedia_assets_js' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
...
...
$builder
->add('medias', 'mmmedia_upload_collection', array(
// optional: configure allowed filetypes by file-extensions
'allowed_filetypes' => array(
'.jpg', '.png', '.gif'
)
));
...