API Reference
Notification (Abstract Class)
Namespace: WPZylos\Framework\Notification
Abstract base class for all notifications. Extend this class and implement via().
Properties
| Property | Type | Description |
|---|---|---|
$id | ?string | Unique notification identifier. Null by default. |
Methods
| Method | Returns | Description |
|---|---|---|
via() | string[] | (abstract) Returns channel names for delivery |
toMail(object $notifiable) | ?MailMessage | Format notification for mail channel. Returns null by default. |
toDatabase(object $notifiable) | array | Format notification for database channel. Returns [] by default. |
toAdminNotice(object $notifiable) | ?AdminNoticeMessage | Format notification for admin notice channel. Returns null by default. |
type() | string | Returns the FQCN of the notification class. |
NotificationManager
Namespace: WPZylos\Framework\Notification
Central dispatcher that routes notifications to registered channels.
Methods
| Method | Returns | Description |
|---|---|---|
send(object|array $notifiables, Notification $notification) | void | Send notification to one or more notifiables |
channel(string $name) | NotificationChannel | Resolve a channel by name. Throws InvalidArgumentException if not registered. |
extend(string $name, NotificationChannel $channel) | void | Register a custom channel |
hasChannel(string $name) | bool | Check if a channel is registered |
channelNames() | string[] | Get all registered channel names |
Notifiable (Trait)
Namespace: WPZylos\Framework\Notification
Add notification capabilities to any model or entity.
Methods
| Method | Returns | Description |
|---|---|---|
notify(Notification $notification) | void | Send a notification to this entity |
notifications() | array | Get all database notifications (newest first) |
unreadNotifications() | array | Get unread database notifications |
readNotifications() | array | Get read database notifications |
markNotificationAsRead(int $id) | void | Mark a notification as read |
routeNotificationFor(string $channel) | mixed | Get routing value for a channel. Override in consuming class. |
MailMessage
Namespace: WPZylos\Framework\Notification
Fluent DTO for composing email notification content.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
$subject | string | '' | Email subject line |
$greeting | string | '' | Greeting line |
$lines | string[] | [] | Body lines |
$actionText | string | '' | CTA button text |
$actionUrl | string | '' | CTA button URL |
$level | string | 'info' | Message level: info, success, error |
Methods
| Method | Returns | Description |
|---|---|---|
subject(string $subject) | static | Set the subject line |
greeting(string $greeting) | static | Set the greeting |
line(string $line) | static | Append a body line |
action(string $text, string $url) | static | Set the CTA button |
level(string $level) | static | Set the message level |
render() | string | Render as HTML |
AdminNoticeMessage
Namespace: WPZylos\Framework\Notification
Fluent DTO for composing WordPress admin dashboard notices.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
$message | string | '' | Notice text |
$type | string | 'info' | Notice type: success, error, warning, info |
$dismissible | bool | true | Whether the notice is dismissible |
Methods
| Method | Returns | Description |
|---|---|---|
message(string $message) | static | Set the notice text |
type(string $type) | static | Set the notice type |
dismissible(bool $dismissible) | static | Set dismissible state |
render() | string | Render as HTML |
NotificationChannel (Interface)
Namespace: WPZylos\Framework\Notification\Contracts
Contract for notification delivery channels.
Methods
| Method | Returns | Description |
|---|---|---|
send(object $notifiable, Notification $notification) | void | Deliver the notification |
MailChannel
Namespace: WPZylos\Framework\Notification\Channels
Delivers notifications via email using WPZylos MailManager or wp_mail().
Constructor
public function __construct(?object $mailManager = null)
$mailManager— Optional WPZylos MailManager instance. Ifnull, falls back towp_mail().
DatabaseChannel
Namespace: WPZylos\Framework\Notification\Channels
Persists notifications in the {prefix}_notifications database table.
Constructor
public function __construct(Connection $connection)
$connection— WPZylos DatabaseConnectioninstance.
AdminNoticeChannel
Namespace: WPZylos\Framework\Notification\Channels
Stores admin notices in WordPress transients and renders them via admin_notices hook.
Constructor
public function __construct(ContextInterface $context)
$context— WPZylos CoreContextInterfacefor prefixed transient keys.
DatabaseNotificationInstaller
Namespace: WPZylos\Framework\Notification
Creates and drops the notifications database table.
Constructor
public function __construct(Connection $connection, ContextInterface $context)
Methods
| Method | Returns | Description |
|---|---|---|
install() | void | Create the notifications table via dbDelta() |
uninstall() | void | Drop the notifications table |
Table Schema
| Column | Type | Description |
|---|---|---|
id | bigint(20) unsigned | Auto-increment primary key |
type | varchar(255) | Notification class FQCN |
notifiable_type | varchar(255) | Notifiable entity class FQCN |
notifiable_id | bigint(20) unsigned | Notifiable entity ID |
data | longtext | JSON-encoded notification data |
read_at | datetime | Timestamp when read (null = unread) |
created_at | datetime | Creation timestamp |
NotificationServiceProvider
Namespace: WPZylos\Framework\Notification
Registers all notification services in the application container.
Methods
| Method | Returns | Description |
|---|---|---|
register(ApplicationInterface $app) | void | Register manager, channels, and installer |
boot(ApplicationInterface $app) | void | Hook into wpzylos_resolve_service for trait resolution |
Container Bindings
| Abstract | Type | Description |
|---|---|---|
NotificationManager::class | Singleton | Central notification dispatcher |
'notification' | Singleton (alias) | Alias for NotificationManager |
DatabaseNotificationInstaller::class | Bound | Table installer (requires Connection) |