コード例 #1
0
 /**
  * Take care of updating file in the database and file storage
  *
  * @param FileCreateOrUpdateEvent $event Image event
  *
  * @throws \Thelia\Exception\FileException
  */
 public function updateFile(FileCreateOrUpdateEvent $event)
 {
     // Copy and save file
     if ($event->getUploadedFile()) {
         // Remove old picture file from file storage
         $url = $event->getModel()->getUploadDir() . '/' . $event->getOldModel()->getFile();
         unlink(str_replace('..', '', $url));
         $newUploadedFile = $this->fileManager->copyUploadedFile($event->getModel(), $event->getUploadedFile());
         $event->setUploadedFile($newUploadedFile);
     }
     // Update image modifications
     $event->getModel()->save();
     $event->setModel($event->getModel());
 }