コード例 #1
0
ファイル: Gallery.php プロジェクト: hexmedia/content-bundle
 /**
  * Add media to gallery
  *
  * @param Media $media
  * @return Gallery
  */
 public function addMedia(Media $media)
 {
     $this->media[] = $media;
     $media->addGallery($this);
     return $this;
 }
コード例 #2
0
 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  * @Rest\View
  */
 public function multipleAction(Request $request)
 {
     $entityManager = $this->getDoctrine()->getManager();
     $form = $this->createForm(new UploadForm());
     if ($form instanceof \Symfony\Component\Form\Form) {
     }
     if ($request->getMethod() == "POST") {
         $form->handleRequest($request);
         if ($form->isValid()) {
             foreach ($form->getData("files") as $file) {
                 $media = new Media();
                 $media->setFile($file);
                 $entityManager->persist($media);
             }
             $this->get('session')->getFlashBag()->add('notice', 'Files has beed uploaded.');
             $entityManager->flush();
             return $this->redirect($this->get("router")->generate("HexMediaContentMedia"));
         } else {
             $this->get('session')->getFlashBag()->add('error', 'Files has not beed uploaded.');
         }
     }
     return ['form' => $form];
 }