Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[8.x] Add support for relative links in filesystem #33882

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

Merged
merged 3 commits into from
Aug 17, 2020
Merged

[8.x] Add support for relative links in filesystem #33882

merged 3 commits into from
Aug 17, 2020

Conversation

MrMicky-FR
Copy link
Contributor

@MrMicky-FR MrMicky-FR commented Aug 14, 2020

This PR add support for relative symlinks in Filesystem, simply by moving the code from StorageLinkCommand to Filesystem so it's reusable.

With this, relative links can be directly created in the framework or in an Laravel application without the need to add the same code to make relatives links outside of the StorageLinkCommand.

// Before 
$target = (new \Symfony\Component\Filesystem\Filesystem())->makePathRelative($target, dirname($link));
File::link($target, $link);

// After
File::relativeLink($target, $link);

@driesvints
Copy link
Member

Might be better to move that to a new relativeLink method instead of adding a boolean param.

@MrMicky-FR
Copy link
Contributor Author

Might be better to move that to a new relativeLink method instead of adding a boolean param.

I added a boolean to make it easier to use it with a condition (like in StorageLinkCommand) without having to add an if/else block, but if you prefer I can move it to a relativeLink method.

@GrahamCampbell
Copy link
Member

I think a separate method is best. It was one of Laravel's original design principles to avoid unnecessary boolean parameters, when intent can be better communicated through method names.

@taylorotwell taylorotwell merged commit 0abd5f3 into laravel:master Aug 17, 2020
ngyikp added a commit to ricochetuniverse/ricochet-universe that referenced this pull request Feb 21, 2025
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.

4 participants