Skip to content

Commit

Permalink
Revert changes of #1441
Browse files Browse the repository at this point in the history
  • Loading branch information
sovetski authored Apr 19, 2024
1 parent ec9ad4b commit 38e4c24
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
20 changes: 0 additions & 20 deletions src/Storage/FlysystemStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,4 @@ protected function getFilesystem(PropertyMapping $mapping): FilesystemOperator

return $this->registry->get($mapping->getUploadDestination());
}

public function resolveUri(object|array $obj, ?string $fieldName = null, ?string $className = null): ?string
{
$path = $this->resolvePath($obj, $fieldName, $className, true);

if (empty($path)) {
return null;
}

$mapping = null === $fieldName ?
$this->factory->fromFirstField($obj, $className) :
$this->factory->fromField($obj, $fieldName, $className);
$fs = $this->getFilesystem($mapping);

try {
return $fs->publicUrl($path);
} catch (FilesystemException) {
return $mapping->getUriPrefix().'/'.$path;
}
}
}
23 changes: 0 additions & 23 deletions tests/Storage/Flysystem/AbstractFlysystemStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,27 +158,4 @@ public static function pathProvider(): array
['foo', '/absolute/foo/file.txt', false],
];
}

public function testResolveUri(): void
{
$this->mapping
->expects(self::once())
->method('getUriPrefix')
->willReturn('/uploads');

$this->mapping
->expects(self::once())
->method('getFileName')
->willReturn('file.txt');

$this->factory
->expects(self::once())
->method('fromField')
->with($this->object, 'file_field')
->willReturn($this->mapping);

$path = $this->getStorage()->resolveUri($this->object, 'file_field');

self::assertEquals('/uploads/file.txt', $path);
}
}

0 comments on commit 38e4c24

Please sign in to comment.