-
Notifications
You must be signed in to change notification settings - Fork 523
Make ProviderCache not final #837
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
Conversation
Nyholm
left a comment
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.
Thank you. I think your use case makes sense.
|
Could you write a change log in this provider for a new minor release? |
|
Sure, would this go under a new 4.0.1 release in |
|
You should put it under a new heading called 4.1.0 in this file: https://github.com/geocoder-php/Geocoder/blob/master/src/Provider/Cache/CHANGELOG.md. |
|
Done |
|
Thanks. |
|
Oops, you're right. Fixed now |
|
Thanks |
|
Oops. I see that we both missed to remove the |
|
IMHO, it would be better to pass 4th argument like Inheritance is like regex. If you try to solve something with inheritance, you have 2 problems. Think about this next time you want to remove Not sure if it's possible now due to BC, but I can refactor it in composition manner. ping @Nyholm new ProviderCache($realProvider, $cache, null, function (string $query) {
// namespace logic for keys
}); |
|
@unkind I disagree, dependency injection is not the right way to solve this. By using that method you have no access to the cache instance itself, which may itself have some properties or methods that are necessary to compute the cache key. Your method also forces the re-declaration of the method upon instantiation, which isn't always necessary or desired. |
Do you mean new ProviderCache($realProvider, $cache, null, function (string $query) use ($cache) {
// namespace logic for keys and you have $cache instance here
});?
Can you provide the use case?
You can use DI-factories to instantiate just once.
Even if it is a problem, you may use lazy loading. Your Inheriting concrete classes is a red sign by itself. There are always way to solve it with composition. What if I need to decorate |
What I meant is that re-declaring the method is required even if you are agnostic about its implementation.
I disagree. That's the whole reason why we have abstract classes. If you look at |
No. You can pass
It is implementation of |
|
May I suggest this if you're unhappy with everyone else's implementation? |
Does it mean you can't speak reasonably anymore? |
I'd like my cache keys to be namespaced. The easiest way for me to do so would be to simply override the
getCacheKeymethod to work how I want and pass that to the geocoder. However that's not possible with it being final.I don't want to reimplement every single method (read: copy and paste). Therefore I propose marking this class not final so that this method and the
getNamemethod can be overridden. I have marked the other methods as final and changed the private properties to protected.