Пример #1
0
 /**
  * @param Asset $asset
  */
 private function clearSubAssets(Asset $asset)
 {
     /** @var SubAsset $subAsset */
     foreach ($asset->getSubAssets() as $subAsset) {
         $this->entityManager->remove($subAsset, false);
     }
     $this->entityManager->flush();
 }
Пример #2
0
 /**
  * @param Asset $asset
  * @return string
  */
 public function handleSave(Asset $asset)
 {
     /** @var SubAsset $subAsset */
     foreach ($asset->getSubAssets() as $subAsset) {
         $this->entityManager->remove($subAsset, false);
     }
     $this->entityManager->flush();
     /** If it's the same field, skip initializing and uploading it. */
     if ($asset->getOriginalFileName() !== $asset->getUploadedFile()->getClientOriginalName()) {
         $asset->setOriginalFileName($asset->getUploadedFile()->getClientOriginalName());
         $ext = $asset->getUploadedFile()->guessExtension();
         $asset->setFileType($ext);
         $key = substr(sha1(uniqid()), 0, 15);
         $newFilename = $key . "." . $ext;
         $asset->setFilename($newFilename);
         $this->assetStorage->uploadAsset($asset);
     }
 }
Пример #3
0
 /**
  * @param Asset $asset
  */
 public function removeAsset(Asset $asset)
 {
     if (strlen($asset->getRelativeUrl()) > 20) {
         $this->s3Client->deleteObject(['Key' => $asset->getRelativeUrl(), 'Bucket' => $this->bucket]);
     }
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function getUrlForAsset(Asset $asset)
 {
     return $asset->getRelativeUrl();
 }
Пример #5
0
 /**
  * @param Asset $asset
  */
 public function removeAsset(Asset $asset)
 {
     unlink($this->basePath . $asset->getRelativeUrl());
 }
Пример #6
0
 /**
  * @param Asset $asset
  * @return boolean
  */
 public function supportsAsset(Asset $asset)
 {
     return $asset->isImage();
 }