当前位置: 首页>>代码示例>>PHP>>正文


PHP FilesystemInterface::delete方法代码示例

本文整理汇总了PHP中League\Flysystem\FilesystemInterface::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::delete方法的具体用法?PHP FilesystemInterface::delete怎么用?PHP FilesystemInterface::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\Flysystem\FilesystemInterface的用法示例。


在下文中一共展示了FilesystemInterface::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteFile

 protected function deleteFile($filePath)
 {
     // If file is already gone somewhere, it is OK for us
     if ($this->filesystem->has($filePath) && !$this->filesystem->delete($filePath)) {
         throw new CommandErrorException('The file cannot be removed: ' . $filePath);
     }
 }
开发者ID:kivagant,项目名称:staticus-core,代码行数:7,代码来源:DestroyResourceCommand.php

示例2: delete

 public function delete($spiBinaryFileId)
 {
     try {
         $this->filesystem->delete($spiBinaryFileId);
     } catch (FlysystemNotFoundException $e) {
         throw new BinaryFileNotFoundException($spiBinaryFileId, $e);
     }
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:8,代码来源:Flysystem.php

示例3: delete

 /**
  * Delete an item from the storage if it exists.
  *
  * @param string $key
  *
  * @return void
  */
 public function delete($key)
 {
     try {
         $this->flysystem->delete($key);
     } catch (FileNotFoundException $e) {
         //
     }
 }
开发者ID:AltThree,项目名称:Storage,代码行数:15,代码来源:FlysystemStore.php

示例4: delete

 /**
  * {@inheritdoc}
  */
 public function delete($path)
 {
     try {
         return $this->filesystem->delete($path);
     } catch (FileNotFoundException $exception) {
         return false;
     }
 }
开发者ID:svycka,项目名称:sv-images,代码行数:11,代码来源:FlySystemAdapter.php

示例5: copyFile

 protected function copyFile($fromFullPath, $toFullPath, $replace = false)
 {
     $this->createDirectory(dirname($toFullPath));
     if ($replace) {
         $this->filesystem->delete($toFullPath);
     }
     if (!$this->filesystem->copy($fromFullPath, $toFullPath)) {
         throw new CommandErrorException('File cannot be copied to the path ' . $toFullPath);
     }
 }
开发者ID:kivagant,项目名称:staticus-core,代码行数:10,代码来源:CopyResourceCommand.php

示例6: handle

 public function handle(DeleteAvatarCommand $command)
 {
     $user = $this->users->findOrFail($command->userId);
     // Make sure the current user is allowed to edit the user profile.
     // This will let admins and the user themselves pass through, and
     // throw an exception otherwise.
     $user->assertCan($command->actor, 'edit');
     $avatarPath = $user->avatar_path;
     $user->changeAvatarPath(null);
     event(new AvatarWillBeDeleted($user, $command));
     $this->uploadDir->delete($avatarPath);
     $user->save();
     $this->dispatchEventsFor($user);
     return $user;
 }
开发者ID:Qiang1234,项目名称:core,代码行数:15,代码来源:DeleteAvatarCommandHandler.php

示例7: gc

 /**
  * Cleanup old sessions
  * @link http://php.net/manual/en/sessionhandlerinterface.gc.php
  * @param int $maxlifetime <p>
  * Sessions that have not updated for
  * the last maxlifetime seconds will be removed.
  * </p>
  * @return bool <p>
  * The return value (usually TRUE on success, FALSE on failure).
  * Note this value is returned internally to PHP for processing.
  * </p>
  * @since 5.4.0
  */
 public function gc($maxlifetime)
 {
     $files = Finder::create()->in($this->path)->files()->ignoreDotFiles(true)->date('<= now - ' . $maxlifetime . ' seconds');
     foreach ($files as $file) {
         $this->driver->delete($file->getRealPath());
     }
 }
开发者ID:AnonymPHP,项目名称:Anonym-Session,代码行数:20,代码来源:FileSessionHandler.php

示例8:

 function it_can_remove_old_backups(FilesystemInterface $filesystem)
 {
     $files = [['path' => '.gitignore'], ['path' => 'foo.sql'], ['path' => 'foo1.sql'], ['path' => 'foo2.sql'], ['path' => 'foo3.sql'], ['path' => 'foo4.sql'], ['path' => 'foo5.sql'], ['path' => 'foo6.sql']];
     $filesystem->listFiles()->willReturn($files);
     $filesystem->getTimestamp('foo.sql')->willReturn(10000);
     $filesystem->getTimestamp('foo1.sql')->willReturn(500);
     $filesystem->getTimestamp('foo2.sql')->willReturn(10000);
     $filesystem->getTimestamp('foo3.sql')->willReturn(10000);
     $filesystem->getTimestamp('foo4.sql')->willReturn(100);
     $filesystem->getTimestamp('.gitignore')->willReturn(50);
     $filesystem->getTimestamp('foo5.sql')->willReturn(10000);
     $filesystem->getTimestamp('foo6.sql')->willReturn(10000);
     $filesystem->delete('foo1.sql')->shouldBeCalled();
     $filesystem->delete('foo4.sql')->shouldBeCalled();
     $this->removeOldBackups(5)->shouldReturn(['foo4.sql', 'foo1.sql']);
 }
开发者ID:ricoa,项目名称:laravel.io,代码行数:16,代码来源:BackupCleanerSpec.php

示例9: push

 /**
  * {@inheritdoc}
  */
 public function push(BackupInterface $backup)
 {
     $backupDirectory = $backup->getName();
     if (!$this->flysystem->has($backupDirectory) && !$this->flysystem->createDir($backupDirectory)) {
         throw new DestinationException(sprintf('Unable to create backup directory "%s" in flysystem destination.', $backupDirectory));
     }
     $removedBackupFiles = $this->getFiles($backupDirectory);
     /**
      * @var FileInterface $backupFile
      */
     foreach ($backup->getFiles() as $backupFile) {
         if (isset($removedBackupFiles[$backupFile->getRelativePath()])) {
             unset($removedBackupFiles[$backupFile->getRelativePath()]);
         }
         $path = $backupDirectory . '/' . $backupFile->getRelativePath();
         try {
             if ($this->flysystem->has($path)) {
                 if ($backupFile->getModifiedAt() > new \DateTime('@' . $this->flysystem->getTimestamp($path))) {
                     $resource = fopen($backupFile->getPath(), 'r');
                     $this->flysystem->updateStream($path, $resource);
                     fclose($resource);
                 }
             } else {
                 $resource = fopen($backupFile->getPath(), 'r');
                 $this->flysystem->putStream($path, $resource);
                 fclose($resource);
             }
         } catch (\Exception $e) {
             throw new DestinationException(sprintf('Unable to backup file "%s" to flysystem destination.', $backupFile->getPath()), 0, $e);
         }
     }
     /**
      * @var FileInterface $removedBackupFile
      */
     foreach ($removedBackupFiles as $removedBackupFile) {
         $path = $backupDirectory . '/' . $removedBackupFile->getRelativePath();
         try {
             $this->flysystem->delete($path);
         } catch (\Exception $e) {
             throw new DestinationException(sprintf('Unable to cleanup backup destination "%s" after backup process, file "%s" could not be removed.', $backupDirectory, $path), 0, $e);
         }
     }
     $this->removeEmptyDirectories($backupDirectory);
     if (is_array($this->backups)) {
         $this->backups[$backup->getName()] = $backup;
     }
 }
开发者ID:runopencode,项目名称:backup,代码行数:50,代码来源:FlysystemDestination.php

示例10: delete

 /**
  * Delete the file at a given path.
  *
  * @param  string|array  $paths
  * @return bool
  */
 public function delete($paths)
 {
     $paths = is_array($paths) ? $paths : func_get_args();
     foreach ($paths as $path) {
         $this->driver->delete($path);
     }
     return true;
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:14,代码来源:FilesystemAdapter.php

示例11: handle

 /**
  * @param DeleteAvatar $command
  * @return \Flarum\Core\User
  * @throws PermissionDeniedException
  */
 public function handle(DeleteAvatar $command)
 {
     $actor = $command->actor;
     $user = $this->users->findOrFail($command->userId);
     if ($actor->id !== $user->id) {
         $this->assertCan($actor, 'edit', $user);
     }
     $avatarPath = $user->avatar_path;
     $user->changeAvatarPath(null);
     $this->events->fire(new AvatarWillBeDeleted($user, $actor));
     $user->save();
     if ($this->uploadDir->has($avatarPath)) {
         $this->uploadDir->delete($avatarPath);
     }
     $this->dispatchEventsFor($user, $actor);
     return $user;
 }
开发者ID:flarum,项目名称:core,代码行数:22,代码来源:DeleteAvatarHandler.php

示例12: createAndBackup

 private function createAndBackup($path, $content)
 {
     if ($this->enableBackup) {
         if ($this->backup->has($path)) {
             $this->backup->delete($path);
         }
         $this->backup->write($path, $content);
     }
     $this->master->write($path, $content);
 }
开发者ID:acmephp,项目名称:acmephp,代码行数:10,代码来源:Repository.php

示例13: delete

 /**
  * Delete the file at a given path.
  *
  * @param  string|array  $paths
  * @return bool
  */
 public function delete($paths)
 {
     $paths = is_array($paths) ? $paths : func_get_args();
     foreach ($paths as $path) {
         try {
             $this->driver->delete($path);
         } catch (FileNotFoundException $e) {
             //
         }
     }
     return true;
 }
开发者ID:uxweb,项目名称:framework,代码行数:18,代码来源:FilesystemAdapter.php

示例14: delete

 /**
  * Delete the file at a given path.
  *
  * @param  string|array  $paths
  * @return bool
  */
 public function delete($paths)
 {
     $paths = is_array($paths) ? $paths : func_get_args();
     $success = true;
     foreach ($paths as $path) {
         try {
             if (!$this->driver->delete($path)) {
                 $success = false;
             }
         } catch (FileNotFoundException $e) {
             $success = false;
         }
     }
     return $success;
 }
开发者ID:hannesvdvreken,项目名称:framework,代码行数:21,代码来源:FilesystemAdapter.php

示例15: uploadFile

 protected function uploadFile(UploadedFileInterface $content, $mime, $filePath)
 {
     $uri = $content->getStream()->getMetadata('uri');
     if (!$uri) {
         throw new SaveResourceErrorException('Unknown error: can\'t get uploaded file uri');
     }
     $uploadedMime = $this->filesystem->getMimetype($uri);
     if ($mime !== $uploadedMime) {
         /**
          * Try to remove unnecessary file because UploadFile object can be emulated
          * @see \Staticus\Middlewares\ActionPostAbstract::download
          */
         $this->filesystem->delete($uri);
         throw new WrongRequestException('Bad request: incorrect mime-type of the uploaded file');
     }
     $content->moveTo($filePath);
 }
开发者ID:kivagant,项目名称:staticus-core,代码行数:17,代码来源:SaveResourceMiddlewareAbstract.php


注:本文中的League\Flysystem\FilesystemInterface::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。