Exemplo n.º 1
0
 protected function setUpMedia()
 {
     // Create Media Type
     $documentType = new MediaType();
     $documentType->setName('document');
     $documentType->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');
     $this->mediaTypes['image'] = $imageType;
     $this->mediaTypes['video'] = $videoType;
     // create some tags
     $tag1 = new Tag();
     $tag1->setName('Tag 1');
     $tag2 = new Tag();
     $tag2->setName('Tag 2');
     $this->em->persist($tag1);
     $this->em->persist($tag2);
     $this->em->persist($documentType);
     $this->em->persist($imageType);
     $this->em->persist($videoType);
     $this->em->flush();
 }
Exemplo n.º 2
0
 public function setUp()
 {
     parent::setUp();
     /** @var ObjectManager $em */
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     foreach ($this->mediaTypes as $mediaTypeData) {
         $mediaType = new MediaType();
         $mediaType->setName($mediaTypeData['type']);
         $em->persist($mediaType);
     }
     $em->flush();
     $this->typeManager = new TypeManager($em, $this->mediaTypes, ['file/exe']);
 }
 protected function setUp()
 {
     parent::setUp();
     $this->purgeDatabase();
     $this->em = $this->db('ORM')->getOm();
     $this->fileVersionMetaRepository = $this->em->getRepository('SuluMediaBundle:FileVersionMeta');
     $this->collectionType = new CollectionType();
     $this->collectionType->setName('image');
     $this->collection = new Collection();
     $this->collection->setType($this->collectionType);
     $this->mediaType = new MediaType();
     $this->mediaType->setName('image');
     $this->em->persist($this->collectionType);
     $this->em->persist($this->mediaType);
     $this->em->persist($this->collection);
     $this->em->flush();
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $mediaDocument = new MediaType();
     $mediaDocument->setId(1);
     // force id = 1
     $metadata = $manager->getClassMetaData(get_class($mediaDocument));
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $mediaDocument->setName('document');
     $manager->persist($mediaDocument);
     $mediaImage = new MediaType();
     $mediaImage->setId(2);
     $mediaImage->setName('image');
     $manager->persist($mediaImage);
     $mediaVideo = new MediaType();
     $mediaVideo->setId(3);
     $mediaVideo->setName('video');
     $manager->persist($mediaVideo);
     $mediaAudio = new MediaType();
     $mediaAudio->setId(4);
     $mediaAudio->setName('audio');
     $manager->persist($mediaAudio);
     $manager->flush();
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     // set id manually
     $metadata = $manager->getClassMetaData(MediaType::class);
     $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $mediaDocument = new MediaType();
     $mediaDocument->setId(1);
     $mediaDocument = $manager->merge($mediaDocument);
     $mediaDocument->setName('document');
     $mediaImage = new MediaType();
     $mediaImage->setId(2);
     $mediaImage = $manager->merge($mediaImage);
     $mediaImage->setName('image');
     $mediaVideo = new MediaType();
     $mediaVideo->setId(3);
     $mediaVideo = $manager->merge($mediaVideo);
     $mediaVideo->setName('video');
     $mediaAudio = new MediaType();
     $mediaAudio->setId(4);
     $mediaAudio = $manager->merge($mediaAudio);
     $mediaAudio->setName('audio');
     $manager->flush();
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 /**
  * Get or create a media type.
  *
  * @param string $name Name of media type to created or retrieved
  *
  * @return MediaType
  */
 private function getOrCreateMediaType($name)
 {
     $manager = $this->getEntityManager();
     $collectionType = $manager->getRepository('SuluMediaBundle:MediaType')->findOneByName($name);
     if (!$collectionType) {
         $collectionType = new MediaType();
         $collectionType->setName($name);
         $manager->persist($collectionType);
     }
     return $collectionType;
 }
Exemplo n.º 8
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 createType($name)
 {
     $type = new MediaType();
     $type->setName($name);
     $this->em->persist($type);
     return $type;
 }