當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Filesystem::delete方法代碼示例

本文整理匯總了PHP中Gaufrette\Filesystem::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filesystem::delete方法的具體用法?PHP Filesystem::delete怎麽用?PHP Filesystem::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Gaufrette\Filesystem的用法示例。


在下文中一共展示了Filesystem::delete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: preUpload

 /**
  * Update attachment entity before upload
  *
  * @param File $entity
  */
 public function preUpload(File $entity)
 {
     if ($entity->isEmptyFile()) {
         if ($this->filesystem->has($entity->getFilename())) {
             $this->filesystem->delete($entity->getFilename());
         }
         $entity->setFilename(null);
         $entity->setExtension(null);
         $entity->setOriginalFilename(null);
     }
     if ($entity->getFile() !== null && $entity->getFile()->isFile()) {
         $entity->setOwner($this->securityFacadeLink->getService()->getLoggedUser());
         $file = $entity->getFile();
         if ($entity->getFilename() !== null && $this->filesystem->has($entity->getFilename())) {
             $this->filesystem->delete($entity->getFilename());
         }
         $entity->setExtension($file->guessExtension());
         if ($file instanceof UploadedFile) {
             $entity->setOriginalFilename($file->getClientOriginalName());
             $entity->setMimeType($file->getClientMimeType());
             $entity->setFileSize($file->getClientSize());
         } else {
             $entity->setOriginalFilename($file->getFileName());
             $entity->setMimeType($file->getMimeType());
             $entity->setFileSize($file->getSize());
         }
         $entity->setFilename(uniqid() . '.' . $entity->getExtension());
         if ($this->filesystem->getAdapter() instanceof MetadataSupporter) {
             $this->filesystem->getAdapter()->setMetadata($entity->getFilename(), ['contentType' => $entity->getMimeType()]);
         }
     }
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:37,代碼來源:AttachmentManager.php

示例2: deleteFile

 /**
  * delete the given file
  *
  * @param string $file
  */
 public function deleteFile($file)
 {
     if (!$this->filesystem->has($file)) {
         return;
     }
     $this->filesystem->delete($file);
     $this->cacheManager->remove($file);
 }
開發者ID:CampaignChain,項目名稱:core,代碼行數:13,代碼來源:FileUploadService.php

示例3: clearCache

 /**
  * {@inheritDoc}
  */
 public function clearCache($maxAge)
 {
     $delTime = time() - (int) $maxAge;
     $num = 0;
     foreach ($this->temporaryFilesystem->keys() as $key) {
         if (!$this->temporaryFilesystem->getAdapter()->isDirectory($key)) {
             if ($delTime > $this->temporaryFilesystem->mtime($key)) {
                 $this->temporaryFilesystem->delete($key);
                 $num++;
             }
         }
     }
     return $num;
 }
開發者ID:thrace-project,項目名稱:media-bundle,代碼行數:17,代碼來源:AbstractManager.php

示例4: shouldDeleteFile

 /**
  * @test
  * @group functional
  */
 public function shouldDeleteFile()
 {
     $this->filesystem->write('foo', 'Some content');
     $this->assertTrue($this->filesystem->has('foo'));
     $this->filesystem->delete('foo');
     $this->assertFalse($this->filesystem->has('foo'));
 }
開發者ID:saberyounis,項目名稱:Sonata-Project,代碼行數:11,代碼來源:FunctionalTestCase.php

示例5: shouldWorkWithHiddenFiles

 /**
  * @test
  * @group functional
  */
 public function shouldWorkWithHiddenFiles()
 {
     $this->filesystem->write('.foo', 'hidden');
     $this->assertTrue($this->filesystem->has('.foo'));
     $this->assertContains('.foo', $this->filesystem->keys());
     $this->filesystem->delete('.foo');
     $this->assertFalse($this->filesystem->has('.foo'));
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:12,代碼來源:FunctionalTestCase.php

示例6: shouldWrtieToSameFile

 /**
  * @test
  * @group functional
  */
 public function shouldWrtieToSameFile()
 {
     $FileObjectA = $this->filesystem->createFile('somefile');
     $FileObjectA->setContent('ABC');
     $FileObjectB = $this->filesystem->createFile('somefile');
     $FileObjectB->setContent('DEF');
     $this->assertEquals('DEF', $FileObjectB->getContent());
     $this->filesystem->delete('somefile');
 }
開發者ID:course-hero,項目名稱:gaufrette-extras,代碼行數:13,代碼來源:FunctionalTestCase.php

示例7: delete

 /**
  * Delete a file
  * @param AbstractProductMedia $media
  */
 protected function delete(AbstractProductMedia $media)
 {
     if ($media->getFilename() !== "" && $this->fileExists($media)) {
         $this->filesystem->delete($media->getFilename());
     }
     $media->setOriginalFilename(null);
     $media->setFilename(null);
     $media->setFilepath(null);
     $media->setMimeType(null);
 }
開發者ID:javiersantos,項目名稱:pim-community-dev,代碼行數:14,代碼來源:MediaManager.php

示例8: cleanup

 public function cleanup(UserProfile $prop)
 {
     if ($prop->getProperty()->getFieldType() === ProfileProperty::TYPE_FILE) {
         /*$fileName = str_replace($this->getBaseFileUrl() . '/', '', $prop->getPropertyValue());
           if ( is_file($this->getBaseFilePath() . '/' . $fileName) ) {
               echo 'maybe removing ' . $this->getBaseFilePath() . '/' . $fileName;
               @unlink($this->getBaseFilePath() . '/' . $fileName);
           }*/
         $fileKey = AbstractUploader::extractKey($prop->getPropertyValue(), $this->awsBucket);
         if ($fileKey && $this->filesystem->has($fileKey)) {
             $this->filesystem->delete($fileKey);
         }
     }
 }
開發者ID:scottstuff,項目名稱:GCProtractorJS,代碼行數:14,代碼來源:UserPropertyHandler.php

示例9: remove

 /**
  * Delete an image from the remote.
  *
  * @param Image $image
  *
  * @return $this
  */
 public function remove(Image $image)
 {
     $this->filesystem->delete($image->getKey());
     $this->untag($image->getKey());
     return $this;
 }
開發者ID:bravo3,項目名稱:image-manager,代碼行數:13,代碼來源:ImageManager.php

示例10: remove

 /**
  * {@inheritdoc}
  */
 public function remove($path)
 {
     return $this->filesystem->delete($path);
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:7,代碼來源:ImageUploader.php

示例11: deleteImage

 /**
  * Deletes an image.
  *
  * @param string $imagePath
  *
  * @return boolean
  */
 public function deleteImage($imagePath)
 {
     return $this->files->delete($imagePath);
 }
開發者ID:Zylius,項目名稱:GalerijaAPI,代碼行數:11,代碼來源:ImageStoreService.php

示例12: delete

 public function delete($id)
 {
     $this->assertHasObject($id);
     $this->filesystem->delete($id);
 }
開發者ID:radnan,項目名稱:rdn-upload,代碼行數:5,代碼來源:Gaufrette.php

示例13: remove

 /**
  * {@inheritdoc}
  */
 public function remove($path)
 {
     $path = $this->stripLeadingSlash($path);
     if (!$this->getAdapter()->isDirectory($path)) {
         parent::delete($path);
         return;
     }
     $keys = $this->listKeys($path);
     foreach ($keys['keys'] as $tmp) {
         parent::delete($tmp);
     }
     // sort array according after directory depth (DESC)
     $directories = array_unique($keys['dirs']);
     usort($directories, function ($left, $right) {
         $depthLeft = substr_count($left, '/');
         $depthRight = substr_count($right, '/');
         if ($depthLeft == $depthRight) {
             return 0;
         } else {
             return $depthLeft > $depthRight ? -1 : +1;
         }
     });
     foreach ($directories as $tmp) {
         parent::delete($tmp);
     }
     if ($path != '' && $this->exists($path)) {
         parent::delete($path);
     }
 }
開發者ID:aboutcoders,項目名稱:file-distribution,代碼行數:32,代碼來源:Filesystem.php

示例14: remove

 /**
  * {@inheritdoc}
  */
 public function remove($name)
 {
     return $this->filesystem->delete($name);
 }
開發者ID:dasklney,項目名稱:kreta,代碼行數:7,代碼來源:MediaUploader.php

示例15:

 function it_does_not_remove(Filesystem $filesystem)
 {
     $filesystem->delete('media-name')->shouldBeCalled()->willReturn(false);
     $this->remove('media-name')->shouldReturn(false);
 }
開發者ID:cespedosa,項目名稱:kreta,代碼行數:5,代碼來源:MediaUploaderSpec.php


注:本文中的Gaufrette\Filesystem::delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。