-
Notifications
You must be signed in to change notification settings - Fork 177
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
Make the download url method more re-usable/overloadable #20
base: master
Are you sure you want to change the base?
Conversation
Making the URL generation method public might be a good idea, but introduce a whole another helper function just for slug-based URLs? I'd say |
Actually there is a reason for that: as you used type hinting, a method overloading the original can only have a Wpup_Package object as the first parameter. The actual implementation I'm using it in is one which needs the download url to be a package attribute, so when you generate the download url, the package object isn't available yet. So that's how I ended up with the currently suggested PR ;-) |
That's actually a pretty big change in dependencies. Instead of generating a download URL for a package, it inverts that by building a package instance using a download URL. I doubt it's realistically possible for an API to support both of those approaches at the same time. The deeper questions seems to be, does the download URL belong to a package, or is it something that pertains to the server itself? I'd say it's a responsibility of the server since it can change without the package changing (server base URL changes, etc). On the other hand, treating it as a property of the package is also reasonable. This, however, makes the package more tightly coupled to the server implementation/configuration since you can't get the URL without involving the server somehow. That's not necessarily wrong, but it changes the meaning of what a package is. In any case, having two overridable URL generation functions is probably not a good idea; with this PR if someone overrides |
Very true. IMHO it's a package property, the server is only the facilitator and if you'd move server and the download url would change, that wouldn't be much of an issue anyway as the cache would be (should be) regenerated on a different server anyway. The reason for having it split into two is that - again IMHO - even though in the current implementation, they are very closely related, they don't have to be. Anyways, not to worry. I'll overload this in the local implementation. Just thought I'd put it out there as I can imagine other people might run into this as well. |
I'm very happy with current Hopefully, proposed changes won't break that functionality. |
No description provided.