Skip to content

Instantly share code, notes, and snippets.

@rande
Created February 24, 2012 14:08
Show Gist options
  • Save rande/1901137 to your computer and use it in GitHub Desktop.
Save rande/1901137 to your computer and use it in GitHub Desktop.
SonataMediaBundle : persist media
<?php
$media = new Media;
$media->setProviderName('sonata.media.provider.image');
$media->setContext('default');
$media->setBinaryContent('/path/to/file');
$post = new Post;
$post->setMedia($media);
$doctrine->getEntityManager()->persist($post);
$doctrine->getEntityManager()->flush();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment