-
Notifications
You must be signed in to change notification settings - Fork 19
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
feature: add channel registry #251
Conversation
The Though this achieves creating a channel with translations for title and description. wp-feature-notifications/wp-feature-notifications.php Lines 74 to 81 in a33543c
|
a33543c
to
14dfc8e
Compare
This looks a lot cleaner to me, though PHP doesn't help with type hinting the array. Named arguments would be most preferred, but that would require a minimum PHP version of 8. wp-feature-notifications/wp-feature-notifications.php Lines 77 to 86 in cb4954e
|
6098a52
to
e4f5897
Compare
8ee8cb9
to
a57fbd2
Compare
includes/class-channel.php
Outdated
* | ||
* Instantiates a Channel object. | ||
* | ||
* @see WP\Notifications\register_channel() |
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.
wasn't something like this?
@see \WP\Notifications\register_channel()
fe869eb
to
9831729
Compare
Blocked by #255 |
Work on this is being continued in #259 |
What?
Add a
Channel_Registry
class to register notification channels.Why?
To attempt registering channels in code.
Implementing the data model of PR #168 has the challenge of when and how to look up plugin registered channels. If channel data is stored in a database table and an integer
id
column is used to link a channel to subscription and messages, how does a plugin know theid
of the channel it registered? This data would have to be looked up on message emit, and also there wouldn't be a good mechanism to prevent plugins from registering similarly named channels.Using a registry similar block types might work well. The channel is registered in code and the channel name/key/slug (as in
core/post-edit
) would link a message source to its channel. Subscriptions could also use the same key to link users to channels. This would also allow checking for conflicts at channel registration.Keeping in mind that if/when a plugin is uninstalled, a message has to contain all the data required to render, it is necessary to store channel key and title in the message.
Both systems have pros and cons. This strategy removes the need for a channel table, and simplifies the logic of emitting a message. Though it will result in duplication of data in the database.
How?
Channel_Registry
class, heavy based on coreBlock_Type_Registry
Channel
classregister_channel
functionFurther considerations
icon
could be stored in the message'sicon
column if/when a message doesn't specify it's own.