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


PHP Filesystem::readAndDelete方法代码示例

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


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

示例1: testReadAndDeleteFailedRead

 public function testReadAndDeleteFailedRead()
 {
     $path = 'path.txt';
     $this->prophecy->has($path)->willReturn(true);
     $this->prophecy->read($path)->willReturn(false);
     $response = $this->filesystem->readAndDelete($path);
     $this->assertFalse($response);
 }
开发者ID:mechiko,项目名称:staff-october,代码行数:8,代码来源:FilesystemTests.php

示例2: readAndDelete

 /**
  * @inheritdoc
  */
 public function readAndDelete($path)
 {
     $innerPath = $this->getInnerPath($path);
     try {
         $return = $this->fileSystem->readAndDelete($innerPath);
     } catch (FileNotFoundException $e) {
         throw $this->exceptionWrapper($e, $path);
     }
     if ($return !== false) {
         $this->invokePlugin("removePathFromIndex", [$path, $innerPath], $this);
     }
     return $return;
 }
开发者ID:petrknap,项目名称:php-filestorage,代码行数:16,代码来源:FileSystem.php

示例3: testReadAndDeleteFail

 public function testReadAndDeleteFail()
 {
     $path = 'path.ext';
     $expected = false;
     $mock = Mockery::mock('League\\Flysystem\\Adapter\\AbstractAdapter[has,read,delete]');
     $adapter = new Filesystem($mock);
     $mock->shouldReceive('has')->andReturn(true);
     $mock->shouldReceive('read')->once()->with($path)->andReturn($expected);
     $result = $adapter->readAndDelete($path);
     $this->assertEquals($expected, $result);
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:11,代码来源:FilesystemTests.php

示例4: handle

 /**
  * Handles the command execution.
  *
  * @param UploadImage $command
  * @return null|string
  *
  * @todo check permission
  */
 public function handle(UploadImage $command)
 {
     // check if the user can upload images, otherwise return
     $this->assertCan($command->actor, 'flagrow.image.upload');
     $tmpFile = tempnam($this->app->storagePath() . '/tmp', 'image');
     $command->file->moveTo($tmpFile);
     $file = new UploadedFile($tmpFile, $command->file->getClientFilename(), $command->file->getClientMediaType(), $command->file->getSize(), $command->file->getError(), true);
     // validate the file
     $this->validator->maxFileSize = $this->settings->get('flagrow.image-upload.maxFileSize', 2048);
     $this->validator->assertValid(['image' => $file]);
     // resize if enabled
     if ($this->settings->get('flagrow.image-upload.mustResize')) {
         $manager = new ImageManager();
         $manager->make($tmpFile)->fit($this->settings->get('flagrow.image-upload.resizeMaxWidth', 100), $this->settings->get('flagrow.image-upload.resizeMaxHeight', 100))->save();
     }
     $image = (new Image())->forceFill(['user_id' => $command->actor->id, 'upload_method' => $this->settings->get('flagrow.image-upload.uploadMethod', 'local'), 'created_at' => Carbon::now(), 'file_name' => sprintf('%d-%s.%s', $command->actor->id, Str::quickRandom(), $file->guessExtension() ?: 'jpg'), 'file_size' => $file->getSize()]);
     // fire the Event ImageWillBeSaved, which can be extended and/or modified elsewhere
     $this->events->fire(new ImageWillBeSaved($command->actor, $image, $file));
     $tmpFilesystem = new Filesystem(new Local(pathinfo($tmpFile, PATHINFO_DIRNAME)));
     $meta = $this->upload->uploadContents($image->file_name, $tmpFilesystem->readAndDelete(pathinfo($tmpFile, PATHINFO_BASENAME)));
     if ($meta) {
         $image->file_url = array_get($meta, 'url');
         if ($image->isDirty()) {
             $image->save();
         }
         return $image;
     }
     return false;
 }
开发者ID:flagrow,项目名称:flarum-ext-image-upload,代码行数:37,代码来源:UploadImageHandler.php

示例5: readAndDelete

 /**
  * Read and delete a file.
  *
  * @param   string $path
  * @return  string|false  file contents
  */
 public function readAndDelete($path)
 {
     if (StringHelper::isRegexp($path) && !($path = $this->searchByPattern($path))) {
         return false;
     }
     try {
         return parent::readAndDelete($path);
     } catch (\Exception $e) {
         $this->errors[] = StringHelper::replace(FileException::UNKNOWN_FILE, ['path' => $path]);
     }
     return false;
 }
开发者ID:romeoz,项目名称:rock-file,代码行数:18,代码来源:FileManager.php


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