diff --git a/src/Storage/FlysystemStorage.php b/src/Storage/FlysystemStorage.php index 00abd008..0cd318ff 100644 --- a/src/Storage/FlysystemStorage.php +++ b/src/Storage/FlysystemStorage.php @@ -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; } diff --git a/tests/Storage/Flysystem/AbstractFlysystemStorageTestCase.php b/tests/Storage/Flysystem/AbstractFlysystemStorageTestCase.php index 489bfba3..3e83c504 100644 --- a/tests/Storage/Flysystem/AbstractFlysystemStorageTestCase.php +++ b/tests/Storage/Flysystem/AbstractFlysystemStorageTestCase.php @@ -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