当前位置: 首页>>代码示例>>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;未经允许,请勿转载。