setName() public method

public setName ( string $name )
$name string
Ejemplo n.º 1
0
 public function create() : MediaInterface
 {
     $media = new Media();
     $media->setSize(0);
     $media->setName('');
     $media->setMime('');
     $media->setExtension('');
     $media->setPath('');
     return $media;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function save(UploadedFile $file, $dir)
 {
     $media = new Media();
     $media->setName($file->getClientOriginalName());
     $media->setExtension($file->guessClientExtension());
     $media->setMime($file->getClientMimeType());
     $media->setSize($file->getClientSize());
     $this->_em->persist($media);
     $this->_em->flush();
     return $media;
 }
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $rootPath = $this->container->get('kernel')->getRootDir() . '/../web/themes/wellcommerce/assets/prod/';
     $uploader = $this->container->get('media.uploader');
     $uploadPath = $uploader->getUploadRootDir('images');
     $filesystem = $this->container->get('filesystem');
     foreach (self::$samples as $photo) {
         $image = new UploadedFile($rootPath . $photo, $photo, 'image/jpeg', filesize($rootPath . $photo));
         $media = new Media();
         $media->setName($image->getClientOriginalName());
         $media->setExtension($image->guessClientExtension());
         $media->setMime($image->getClientMimeType());
         $media->setSize($image->getClientSize());
         $manager->persist($media);
         $filesystem->copy($rootPath . $photo, $uploadPath . '/' . $media->getPath());
         $this->setReference('photo_' . $photo, $media);
     }
     $manager->flush();
 }