Skip to content

Commit

Permalink
add more context to public uri generation
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-sainthillier committed Jan 24, 2025
1 parent f86dfa7 commit f4bd3c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Storage/FlysystemStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ public function resolveUri(object|array $obj, ?string $fieldName = null, ?string
$fs = $this->getFilesystem($mapping);

try {
return $fs->publicUrl($path);
return $fs->publicUrl($path, [
'object' => $obj,
'fieldName' => $fieldName,
'className' => $className,
'mapping' => $mapping,
]);
} catch (FilesystemException|UndefinedMethodError) {
return $mapping->getUriPrefix().'/'.$path;
}
Expand Down
7 changes: 6 additions & 1 deletion tests/Storage/Flysystem/AbstractFlysystemStorageTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ public function testResolveUriThroughFlysystem(): void
$this->filesystem
->expects(self::once())
->method('publicUrl')
->with('file.txt')
->with('file.txt', [
'object' => $this->object,
'fieldName' => 'file_field',
'className' => null,
'mapping' => $this->mapping,
])
->willReturn('example.com/file.txt');

$this->mapping
Expand Down

0 comments on commit f4bd3c4

Please sign in to comment.