Beispiel #1
0
 public function preUpload(PreUploadEvent $event)
 {
     //echo "preUpload";die();
     /*$response = $event->getResponse();
       $msg = "test";
       $response->setSuccess(false);
       $response->setError($msg);*/
     $galleryId = $event->getRequest()->get('galleryId');
     $file = $event->getFile();
     $media = new Media();
     //$media->setName($file->getBasename());
     $media->setName($file->getClientOriginalName());
     $media->setBinaryContent($file);
     $media->setEnabled(true);
     $media->setContext('default');
     $media->setProviderName('sonata.media.provider.image');
     $this->em = $this->doctrine[0]->getEntityManager();
     $gallery = $this->em->getRepository('ApplicationSonataMediaBundle:Gallery')->find($galleryId);
     $galleryHasMedia = new GalleryHasMedia();
     $galleryHasMedia->setMedia($media);
     $galleryHasMedia->setEnabled(true);
     $gallery->addGalleryHasMedias($galleryHasMedia);
     $this->em->persist($galleryHasMedia);
     $this->em->persist($media);
     $this->em->flush();
     die;
 }
 /**
  * Methode petmettant de mettre en session les paramètres envoyés
  *
  * @param PreUploadEvent $event
  */
 public function onUpload(PreUploadEvent $event)
 {
     $req = $event->getRequest();
     $this->session->set('filename', $req->get('filename'));
     $this->session->set('quantite', $req->get('quantite'));
     $this->session->set('date', $req->get('day'));
     $this->session->set('method', $req->get('method'));
 }
Beispiel #3
0
 /**
  * Saves the uploaded file onto the database
  * @param PreUploadEvent $event
  * @throws \ErrorException
  */
 public function preUpload(PreUploadEvent $event)
 {
     $file = $event->getFile();
     $album = $this->manager->getRepository('ColibriGalleryBundle:Album')->find($event->getRequest()->get('albumid'));
     $this->pm->uploadToAlbum($file, $album);
 }