-
Notifications
You must be signed in to change notification settings - Fork 202
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
Custom path callable #282
Custom path callable #282
Conversation
What's your use case for this? I'm not fundamentally against adding it, but I don't think users need should care about the internal structure of the cache. I may be missing a valid use case though. |
That's an interesting idea indeed. @mlazze are you still interested in finalizing this PR? It needs rebasing and I have some comments on the code but I prefer to ask before moving forward on this PR :) . |
Yes, i'm customizing the path callable to allow the ws to cache images. I'm also using that to add custom meta information to the path (that's beyond the scope of this library, but i still need that :D ) , so this allows me to customize everything about the cache path generation. I'm willing to finalize this PR and rebase it (in a few days :D) |
18fdada
to
0dd257b
Compare
Rebased on master. 7.2 fails for missing gd library, i'm not sure why |
Rebasing your branch onto upstream master should fix that. |
0dd257b
to
cdd9aa0
Compare
cdd9aa0
to
5cb1378
Compare
Hello, just switched from callable to Closure and rebased on master. |
I may also add return type hints if needed, but i'm not seeing them in the codebase. |
@@ -349,6 +375,12 @@ public function getCacheWithFileExtensions() | |||
*/ | |||
public function getCachePath($path, array $params = []) | |||
{ | |||
$customCallable = $this->getCachePathCallable(); | |||
if (null !== $customCallable) { | |||
$boundCallable = \Closure::bind($customCallable, $this, self::class); |
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.
Since you are binding current object's context can you please add a test for it too. For e.g. calling $this->getSourcePath()
inside the callable.
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.
@mlazze Ping
Is there any update? Appreciate for the effort anyway. |
Is there any update for this? Thanks. |
This would allow to customize the cache path fully.
An alternative would be to call the callable at the end of getCachePath with all the calculated parts (sourcePath, md5, groupCacheInFolders, cachePathPrefix, cacheWithFileExtensions, ext).
I also bound this to the Server instance so that we may its method within the callable.