Skip to content

Commit

Permalink
Merge pull request #159 from Kunstmaan/fix_aviary_save
Browse files Browse the repository at this point in the history
create a new file and kuma_media entry when you click save in the aviary plugin
  • Loading branch information
Devolicious committed Aug 19, 2014
2 parents 40a3caa + 85e0521 commit f6b4c19
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Controller/AviaryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,20 @@ public function indexAction(Request $request, $folderId, $mediaId)
$media = $em->getRepository('KunstmaanMediaBundle:Media')->getMedia($mediaId);
/* @var MediaManager $mediaManager */
$mediaManager = $this->get('kunstmaan_media.media_manager');

$media = clone $media;
$handler = $mediaManager->getHandler($media);
$fileHelper = $handler->getFormHelper($media);
$fileHelper->getMediaFromUrl($request->get('url'));
$media = $fileHelper->getMedia();

$media->setUuid(null);
$handler->prepareMedia($media);

$em->persist($media);
$em->flush();

$media->setCreatedAt($media->getUpdatedAt());
$em->persist($media);
$em->flush();

Expand Down

0 comments on commit f6b4c19

Please sign in to comment.