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

making original file info available in callback for adhoc requirements #173

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ First, start off by creating a `generation.php` config file in the `config` dire
```php
<?php

use Symfony\Component\Finder\SplFileInfo;

return [
[
// Define a source directory for the sets like a node_modules/ or vendor/ directory...
Expand All @@ -544,9 +546,9 @@ return [
// Enable "safe" mode which will prevent deletion of old icons...
'safe' => true,

// Call an optional callback to manipulate the icon
// with the pathname of the icon and the settings from above...
'after' => static function (string $icon, array $config) {
// Call an optional callback to manipulate the icon with the pathname of the icon,
// the settings from above and the original icon file instance...
'after' => static function (string $icon, array $config, SplFileInfo $file) {
// ...
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/Generation/IconGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

}
}
}
Expand Down