本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}