replaceFromFilesystem() public method

Replaces the current file with a new file.
public replaceFromFilesystem ( UploadedFile $file, File $filesystemFile )
$file PartKeepr\UploadedFileBundle\Entity\UploadedFile The target file
$filesystemFile Symfony\Component\HttpFoundation\File\File The source file
 protected function createManufacturer($manufacturerName, $manufacturerData)
 {
     $manufacturer = new Manufacturer();
     $manufacturer->setName($manufacturerName);
     if (array_key_exists('iclogos', $manufacturerData)) {
         foreach ($manufacturerData['iclogos'] as $icLogo) {
             $manufacturerIcLogo = new ManufacturerICLogo();
             $file = $this->kernel->locateResource(self::MANUFACTURER_PATH . $icLogo);
             $this->uploadedFileService->replaceFromFilesystem($manufacturerIcLogo, new File($file));
             $manufacturer->addIcLogo($manufacturerIcLogo);
         }
     }
     $this->entityManager->persist($manufacturer);
 }
 protected function createFootprint($footprintName, $footprintData)
 {
     /**
      * @var FootprintCategory
      */
     $footprintCategoryRootNode = $this->footprintCategoryService->getRootNode();
     $footprint = new Footprint();
     $footprint->setName($footprintName);
     if (array_key_exists('description', $footprintData)) {
         $footprint->setDescription($footprintData['description']);
     }
     if (array_key_exists('category', $footprintData)) {
         $footprintCategory = $this->addFootprintCategoryPath(explode('/', $footprintData['category']), $footprintCategoryRootNode);
         $footprint->setCategory($footprintCategory);
     }
     if (array_key_exists('image', $footprintData)) {
         $footprintImage = new FootprintImage();
         $file = $this->kernel->locateResource(self::FOOTPRINT_PATH . $footprintData['image']);
         $this->uploadedFileService->replaceFromFilesystem($footprintImage, new File($file));
         $footprint->setImage($footprintImage);
     }
     $this->entityManager->persist($footprint);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function replaceFromFilesystem(UploadedFile $file, File $filesystemFile)
 {
     parent::replaceFromFilesystem($file, $filesystemFile);
     $this->invalidate($file);
 }