final class ChannelRegistry

Registry for notification channel drivers.

This static registry maps short channel names (e.g., "database", "mail") to their concrete {\Core\Lib\Notifications\Contracts\Channel} implementation classes. Providers register channels during application boot, and the notifier resolves them at runtime before delivery.

Notes:

  • Registering the same name more than once will overwrite the previous mapping.
  • {\Core\Lib\Notifications\resolve()} instantiates the channel using a no-argument constructor. If your channel requires dependencies, adapt this class to use your container.

Typical flow: 1) A service/provider calls {\Core\Lib\Notifications\ChannelRegistry::register()} during boot. 2) When sending, {\Core\Lib\Notifications\ChannelRegistry::resolve()} returns a Channel instance.

Properties

static private Channel>> $map

Map of channel name => channel class.

Methods

static array
all()

Return array of channel classes.

static bool
has(string $name)

Checks if channel name exists.

static void
register(string $name, string $channelClass)

Register (or override) a channel implementation under a short name.

static Channel
resolve(string $name)

Resolve a channel by name into a concrete {Channel} instance.

Details

at line 44
static array all()

Return array of channel classes.

Return Value

array

The array of channel classes.

at line 54
static bool has(string $name)

Checks if channel name exists.

Parameters

string $name

The name of the channel to check.

Return Value

bool

True if channel name exist. Otherwise, we return false.

at line 68
static void register(string $name, string $channelClass)

Register (or override) a channel implementation under a short name.

Call this during application boot (e.g., in a service provider).

Parameters

string $name

Short identifier used in Notification::via(), e.g. "database".

string $channelClass

Fully-qualified class name implementing {\Core\Lib\Notifications\Contracts\Channel}.

Return Value

void

at line 84
static Channel resolve(string $name)

Resolve a channel by name into a concrete {Channel} instance.

The channel class is instantiated with a zero-argument constructor. If the channel is not registered, a {\RuntimeException} is thrown.

Parameters

string $name

The short channel name to resolve.

Return Value

Channel

The instantiated channel driver.

Exceptions

RuntimeException