Inheritance: extends Symfony\Component\DependencyInjection\ContainerAware
Ejemplo n.º 1
0
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $em = $eventArgs->getEntityManager();
     $uow = $em->getUnitOfWork();
     foreach ($uow->getScheduledEntityDeletions() as $entity) {
         if ($entity instanceof UploadedFile) {
             $this->uploadedFileService->delete($entity);
         }
     }
 }
 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 replaceFile(UploadedFile $target, UploadedFile $source)
 {
     if ($target instanceof Image) {
         $this->imageService->replaceFromUploadedFile($target, $source);
     } else {
         $this->uploadedFileService->replaceFromUploadedFile($target, $source);
     }
     $target->setDescription($source->getDescription());
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function replaceFromFilesystem(UploadedFile $file, File $filesystemFile)
 {
     parent::replaceFromFilesystem($file, $filesystemFile);
     $this->invalidate($file);
 }