Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve public uri #1491

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guillaume-sainthillier
Copy link
Contributor

This PR needs #1486 before to be merged.

When using publicUri with flysystem, it could be necessary to have more context (the object, mapping and fieldName) to generate a public uri

@@ -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, [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate a bit on this? I don't get why we need to pass our internal information (like the mapping and the field name) to Flysystem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garak sometimes, the url generator must be aware of which object and which fields is getting generated.

For example, an User entity with profilePictureFile (public) and bankDetailFile (private) fields.
The generator must generate a public url for one, and a private url with authorization for the other field.

Passing internals like mapping would not be needed in this case so it can be removed if you think it's not worth it

@garak
Copy link
Collaborator

garak commented Jan 24, 2025

You can ignore the phpstan problem, but the tests need to be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants