setSize() public method

Set size.
public setSize ( integer $size ) : FileVersion
$size integer
return FileVersion
 public function setUpMediaEntities($contact)
 {
     $mediaType = new MediaType();
     $mediaType->setName('document');
     $mediaType->setDescription('This is a document');
     $imageType = new MediaType();
     $imageType->setName('image');
     $imageType->setDescription('This is an image');
     $videoType = new MediaType();
     $videoType->setName('video');
     $videoType->setDescription('This is a video');
     $audioType = new MediaType();
     $audioType->setName('audio');
     $audioType->setDescription('This is an audio');
     $media = new Media();
     $media->setType($imageType);
     $this->media = $media;
     $media2 = new Media();
     $media2->setType($imageType);
     $this->media2 = $media2;
     $contact->addMedia($media2);
     // create file
     $file = new File();
     $file->setVersion(1);
     $file->setMedia($media);
     $file2 = new File();
     $file2->setVersion(1);
     $file2->setMedia($media2);
     // create file version
     $fileVersion = new FileVersion();
     $fileVersion->setVersion(1);
     $fileVersion->setName('photo.jpeg');
     $fileVersion->setMimeType('image/jpg');
     $fileVersion->setFile($file);
     $fileVersion->setSize(1124214);
     $fileVersion->setDownloadCounter(2);
     $fileVersion->setStorageOptions('{"segment":"1","fileName":"photo.jpeg"}');
     $file->addFileVersion($fileVersion);
     // create file version
     $fileVersion = new FileVersion();
     $fileVersion->setVersion(1);
     $fileVersion->setName('photo.jpeg');
     $fileVersion->setMimeType('image/jpg');
     $fileVersion->setFile($file2);
     $fileVersion->setSize(1124214);
     $fileVersion->setDownloadCounter(2);
     $fileVersion->setStorageOptions('{"segment":"1","fileName":"photo.jpeg"}');
     $file2->addFileVersion($fileVersion);
     $collection = new Collection();
     $this->setUpCollection($collection);
     $media->setCollection($collection);
     $media2->setCollection($collection);
     $this->em->persist($media);
     $this->em->persist($media2);
     $this->em->persist($collection);
     $this->em->persist($file);
     $this->em->persist($file2);
     $this->em->persist($videoType);
     $this->em->persist($imageType);
     $this->em->persist($audioType);
     $this->em->persist($mediaType);
 }
Esempio n. 2
0
 protected function createMedia($name)
 {
     $media = new Media();
     $media->setType($this->imageType);
     // create file
     $file = new File();
     $file->setVersion(1);
     $file->setMedia($media);
     // create file version
     $fileVersion = new FileVersion();
     $fileVersion->setVersion(1);
     $fileVersion->setName($name . '.jpeg');
     $fileVersion->setMimeType('image/jpg');
     $fileVersion->setFile($file);
     $fileVersion->setSize(1124214);
     $fileVersion->setDownloadCounter(2);
     $fileVersion->setChanged(new \DateTime('1937-04-20'));
     $fileVersion->setCreated(new \DateTime('1937-04-20'));
     $fileVersion->setStorageOptions('{"segment":"1","fileName":"' . $name . '.jpeg"}');
     if (!file_exists(__DIR__ . '/../../uploads/media/1')) {
         mkdir(__DIR__ . '/../../uploads/media/1', 0777, true);
     }
     copy($this->getImagePath(), __DIR__ . '/../../uploads/media/1/' . $name . '.jpeg');
     // create meta
     $fileVersionMeta = new FileVersionMeta();
     $fileVersionMeta->setLocale('en-gb');
     $fileVersionMeta->setTitle($name);
     $fileVersionMeta->setDescription($this->mediaDefaultDescription);
     $fileVersionMeta->setFileVersion($fileVersion);
     $fileVersion->addMeta($fileVersionMeta);
     $fileVersion->setDefaultMeta($fileVersionMeta);
     $file->addFileVersion($fileVersion);
     $media->addFile($file);
     $media->setCollection($this->collection);
     $this->em->persist($media);
     $this->em->persist($file);
     $this->em->persist($fileVersionMeta);
     $this->em->persist($fileVersion);
     $this->em->flush();
     return $media;
 }
Esempio n. 3
0
 public function initLogo()
 {
     $collectionType = new CollectionType();
     $collectionType->setName('My collection type');
     $this->em->persist($collectionType);
     $collection = new Collection();
     $collection->setType($collectionType);
     $this->em->persist($collection);
     $imageType = new MediaType();
     $imageType->setName('image');
     $imageType->setDescription('This is an image');
     $this->em->persist($imageType);
     $file = new File();
     $file->setVersion(1);
     $fileVersion = new FileVersion();
     $fileVersion->setVersion(1);
     $fileVersion->setName('logo.jpeg');
     $fileVersion->setMimeType('image/jpg');
     $fileVersion->setFile($file);
     $fileVersion->setSize(1124214);
     $fileVersion->setDownloadCounter(2);
     $fileVersion->setChanged(new \DateTime('1937-04-20'));
     $fileVersion->setCreated(new \DateTime('1937-04-20'));
     $file->addFileVersion($fileVersion);
     $this->em->persist($fileVersion);
     $this->logo = new Media();
     $this->logo->setType($imageType);
     $this->logo->setCollection($collection);
     $this->logo->addFile($file);
     $file->setMedia($this->logo);
     $this->em->persist($this->logo);
     $this->em->persist($file);
 }
 private function createFileVersion(File $file, $title, $version)
 {
     $fileVersion = new FileVersion();
     $fileVersion->setName($title . '.png');
     $fileVersion->setVersion($version);
     $fileVersion->setSize(0);
     $fileVersion->setFile($file);
     $fileVersionMeta = new FileVersionMeta();
     $fileVersionMeta->setTitle($title);
     $fileVersionMeta->setLocale('en');
     $fileVersionMeta->setFileVersion($fileVersion);
     $this->em->persist($fileVersion);
     $this->em->persist($fileVersionMeta);
 }