Closed
Conversation
This allows for an extended child class to set the global and for everything to still work provided the child class provides their own static `get_instance()` method which sets their own static `$instance` property.
196aa59 to
36c4fcd
Compare
Contributor
Author
|
Originally - this PR also contained the changes from PR #221 , but it made more sense to split the PR as - while related -, they really are two different things. |
jrfnl
added a commit
to jrfnl/TGM-Plugin-Activation
that referenced
this pull request
Jan 14, 2015
…oading anticipating PR TGMPA#219
Member
|
I'm +1 for this. |
Member
There was a problem hiding this comment.
Instead of having an untestable singleton class, how about we put a static into load_tgm_plugin_activation() instead?
GaryJones
added a commit
that referenced
this pull request
Apr 22, 2015
…implementation The way the class was set up, extending from a child class would mean overloading a truck load of methods to get round the hard coded class name and some more convoluted coding to overrule the instance and the auto-instantiation of the class. These changes take the pain out of extending the class and make it so this library can have a clean upgrade path even when you extend the class. Details: * Wrap instantiation in a hooked function (so it can be unhooked) * Use the global to get to the instance. This allows for an extended child class to set the global and for everything to still work provided the child class provides their own static `get_instance()` method which sets their own static `$instance` property. * Force instantiation via `get_instance()` by making the constructor protected. props jrfnl, see #219
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The changes in this PR allow for the class to be extended from a child class for a specific implementation.
The way the class was set up, extending from a child class would mean overloading a truck load of methods to get round the hard coded class name and some more convoluted coding to overrule the instance and the auto-instantiation of the class.
These changes take the pain out of extending the class and make it so this library can have a clean upgrade path even when you extend the class.
Details:
This allows for an extended child class to set the global and for everything to still work provided the child class provides their own static
get_instance()method which sets their own static$instanceproperty.get_instance()by making the constructor protected