API Reference

Notification (Abstract Class)

Namespace: WPZylos\Framework\Notification

Abstract base class for all notifications. Extend this class and implement via().

Properties

PropertyTypeDescription
$id?stringUnique notification identifier. Null by default.

Methods

MethodReturnsDescription
via()string[](abstract) Returns channel names for delivery
toMail(object $notifiable)?MailMessageFormat notification for mail channel. Returns null by default.
toDatabase(object $notifiable)arrayFormat notification for database channel. Returns [] by default.
toAdminNotice(object $notifiable)?AdminNoticeMessageFormat notification for admin notice channel. Returns null by default.
type()stringReturns the FQCN of the notification class.

NotificationManager

Namespace: WPZylos\Framework\Notification

Central dispatcher that routes notifications to registered channels.

Methods

MethodReturnsDescription
send(object|array $notifiables, Notification $notification)voidSend notification to one or more notifiables
channel(string $name)NotificationChannelResolve a channel by name. Throws InvalidArgumentException if not registered.
extend(string $name, NotificationChannel $channel)voidRegister a custom channel
hasChannel(string $name)boolCheck 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

MethodReturnsDescription
notify(Notification $notification)voidSend a notification to this entity
notifications()arrayGet all database notifications (newest first)
unreadNotifications()arrayGet unread database notifications
readNotifications()arrayGet read database notifications
markNotificationAsRead(int $id)voidMark a notification as read
routeNotificationFor(string $channel)mixedGet routing value for a channel. Override in consuming class.

MailMessage

Namespace: WPZylos\Framework\Notification

Fluent DTO for composing email notification content.

Properties

PropertyTypeDefaultDescription
$subjectstring''Email subject line
$greetingstring''Greeting line
$linesstring[][]Body lines
$actionTextstring''CTA button text
$actionUrlstring''CTA button URL
$levelstring'info'Message level: info, success, error

Methods

MethodReturnsDescription
subject(string $subject)staticSet the subject line
greeting(string $greeting)staticSet the greeting
line(string $line)staticAppend a body line
action(string $text, string $url)staticSet the CTA button
level(string $level)staticSet the message level
render()stringRender as HTML

AdminNoticeMessage

Namespace: WPZylos\Framework\Notification

Fluent DTO for composing WordPress admin dashboard notices.

Properties

PropertyTypeDefaultDescription
$messagestring''Notice text
$typestring'info'Notice type: success, error, warning, info
$dismissiblebooltrueWhether the notice is dismissible

Methods

MethodReturnsDescription
message(string $message)staticSet the notice text
type(string $type)staticSet the notice type
dismissible(bool $dismissible)staticSet dismissible state
render()stringRender as HTML

NotificationChannel (Interface)

Namespace: WPZylos\Framework\Notification\Contracts

Contract for notification delivery channels.

Methods

MethodReturnsDescription
send(object $notifiable, Notification $notification)voidDeliver 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. If null, falls back to wp_mail().

DatabaseChannel

Namespace: WPZylos\Framework\Notification\Channels

Persists notifications in the {prefix}_notifications database table.

Constructor

public function __construct(Connection $connection)
  • $connection — WPZylos Database Connection instance.

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 Core ContextInterface for prefixed transient keys.

DatabaseNotificationInstaller

Namespace: WPZylos\Framework\Notification

Creates and drops the notifications database table.

Constructor

public function __construct(Connection $connection, ContextInterface $context)

Methods

MethodReturnsDescription
install()voidCreate the notifications table via dbDelta()
uninstall()voidDrop the notifications table

Table Schema

ColumnTypeDescription
idbigint(20) unsignedAuto-increment primary key
typevarchar(255)Notification class FQCN
notifiable_typevarchar(255)Notifiable entity class FQCN
notifiable_idbigint(20) unsignedNotifiable entity ID
datalongtextJSON-encoded notification data
read_atdatetimeTimestamp when read (null = unread)
created_atdatetimeCreation timestamp

NotificationServiceProvider

Namespace: WPZylos\Framework\Notification

Registers all notification services in the application container.

Methods

MethodReturnsDescription
register(ApplicationInterface $app)voidRegister manager, channels, and installer
boot(ApplicationInterface $app)voidHook into wpzylos_resolve_service for trait resolution

Container Bindings

AbstractTypeDescription
NotificationManager::classSingletonCentral notification dispatcher
'notification'Singleton (alias)Alias for NotificationManager
DatabaseNotificationInstaller::classBoundTable installer (requires Connection)