예제 #1
0
 /**
  * Create a new media entry
  *
  * @param AbstractClassContent $content
  * @param string $title
  *
  * @return void
  */
 protected function createNewMedia(AbstractClassContent $content, $title = '')
 {
     $newMedia = new NestedNodeMedia();
     $newMedia->setMediaFolder($this->_em->getRepository('BackBee\\NestedNode\\MediaFolder')->getRoot());
     $newMedia->setContent($content);
     $newMedia->setTitle(trim($title . ' [' . $this->request->get('selectedProportion') . ']'));
     $this->_em->persist($newMedia);
     $this->_em->flush();
 }
예제 #2
0
 /**
  * @covers BackBee\NestedNode\Media::setModified
  * @covers BackBee\NestedNode\Media::getModified
  */
 public function testSetAndGetModified()
 {
     $tomorrow = new \DateTime('tomorrow');
     $this->assertEquals($this->media, $this->media->setModified($tomorrow));
     $this->assertEquals($tomorrow, $this->media->getModified());
 }
예제 #3
0
 /**
  * @param  Request $request
  * @return Response
  * @throws BadRequestHttpException
  */
 public function postAction(Request $request)
 {
     $contentUid = $request->request->get('content_uid');
     $contentType = $request->request->get('content_type', null);
     $mediaFolderUid = $request->request->get('folder_uid', null);
     $mediaTitle = $request->request->get('title', 'Untitled media');
     if (null === $mediaFolderUid) {
         $mediaFolder = $this->getMediaFolderRepository()->getRoot();
     } else {
         $mediaFolder = $this->getMediaFolderRepository()->find($mediaFolderUid);
     }
     if (null === $mediaFolder) {
         throw new NotFoundHttpException('Cannot find a media folder');
     }
     if (null !== ($content = $this->getClassContentManager()->findOneByTypeAndUid($contentType, $contentUid))) {
         $this->autoCommitContent($content);
     }
     $media = new Media();
     $media->setContent($content);
     $media->setTitle($mediaTitle);
     $media->setMediaFolder($mediaFolder);
     $this->getEntityManager()->persist($media);
     $this->getEntityManager()->flush();
     return $this->createJsonResponse(null, 201, ['BB-RESOURCE-UID' => $media->getId(), 'Location' => $this->getApplication()->getRouting()->getUrlByRouteName('bb.rest.media.get', ['version' => $request->attributes->get('version'), 'uid' => $media->getId()], '', false)]);
 }
예제 #4
0
파일: Media.php 프로젝트: gobjila/BackBee
 /**
  * @param  \BackBee\ClassContent\AbstractClassContent $content
  * @return string
  *
  * @deprecated since version 0.10.0
  */
 public static function getAbsolutePath($content = null)
 {
     return __DIR__ . '/../../repository/' . Media::getUploadDir();
 }