-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
making original file info available in callback for adhoc requirements #173
making original file info available in callback for adhoc requirements #173
Conversation
Not a bad idea at all! I sorta dislike that it has to be a breaking change - since other packages already use 2 parameter closures. 🤔 |
@mallardduck There's no breaking change here. Existing closures will continue to work as is. Thanks @swapnilsarwe, I'll take a more thorough look at this as soon as I find the time. |
🤦 That's right - sorry forgot PHP does that as a feature rather than throwing an error. |
@@ -40,7 +40,7 @@ public function generate(): void | |||
$this->filesystem->copy($file->getRealPath(), $pathname); | |||
|
|||
if (is_callable($set['after'] ?? null)) { | |||
$set['after']($pathname, $set); | |||
$set['after']($pathname, $set, $file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swapnilsarwe my only thought is around if you want just a string of the path, or the Spl object.
Not sure if it's consequential either way, but could be something worth considering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. It works for me - atleast for my current use case. I can simply pass the string $file->getRealPath()
instead of object of type SplFileObject
.
I was just being little greedy by passing the complete $file
object.
I will make the changes and update the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have made the changes in the PR
0cdf041
to
81df259
Compare
@mallardduck - have made the changes as you had suggested, i doubt whole object would be needed.
@driesvints take your time, i am using the forked version to generate icons in the specific packages where there is a need. They are just a few. |
I don't mind passing the entire file. Could be useful perhaps for other use cases. Thanks @swapnilsarwe @mallardduck |
@driesvints & @mallardduck ,
There are certain icon-sets which store the icons in the respective folder with the same file name.
Eg:
All the files are named as 24.svg under respective folder with folder having the name of the icon.
From the above example, if I have the original file information available in callback, I can rename the file with an appropriate name using the file object passed in this PR
// from above example, lets say my source directory is
dist/src/action/3d_rotation/materialicons/24.svg
Following is the callback method configured in
after
Your thoughts?