Improve connector registration logic #1546
Merged
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.
Fixes #1500.
Connector classes can be validated in a single loop pass and only registered if they pass all the checks. The checks should involve validating that all connector dependencies are satisfied. We should not rely on a third-party to do that for us.
Sample Connector
Note: The following is intended to replace the connector example presented in https://github.com/xwp/stream/wiki/Creating-a-Custom-Connector
A custom connector can be really simple. There are just a few tasks it must do:
Below, you'll find an example of a connector plugin. It's a Stream Observer which logs visits to the Stream Settings and Alerts admin screens. While it would not be useful in a real-life scenario, it can show basic concepts behind Stream connectors really well.
The plugin consists of only 2 files. In the first one, the main file containing the necessary WordPress plugin header, the connector class is registered in Stream via the
wp_stream_connectors
filter:The second file contains the connector class definition:
Here you'll find the list of actions the connector should listen to:
Along with a callback function which calls
$this->log( ... )
to store the record:Checklist
contributing.md
).Release Changelog