class ChannelManager extends Manager implements Dispatcher, Factory

Traits

Constants

protected DEFAULT_CHANNEL_CONTEXT_KEY

Context key for the per-request default channel override.

protected DEFAULT_LOCALE_CONTEXT_KEY

Context key for the next send's locale override.

Properties

protected Repository $config

The configuration repository instance.

from  Manager
protected Closure> $customCreators

The registered custom driver creators.

from  Manager
protected array<array-key, mixed> $drivers

The array of created "drivers".

from  Manager
static protected array $macros

The registered string macros.

from  Macroable
protected string $defaultChannel

The default channel used to deliver messages.

protected string|null $locale

The default notification locale configured during boot.

Methods

Closure|null
bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

__construct(Container $container)

Create a new manager instance.

from  Manager
string|null
getDefaultDriver()

Get the default channel driver name.

mixed
driver(UnitEnum|string|null $driver = null)

Get a driver instance.

from  Manager
mixed
createDriver(string $driver)

Create a new driver instance.

string|null
getCreatorMethod(string $driver)

Get the name of the manager's creator method for the given driver.

from  Manager
mixed
callCustomCreator(string $driver)

Call a custom driver creator.

from  Manager
extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

from  Manager
array
getDrivers()

Get all of the created "drivers".

from  Manager
getContainer()

Get the container instance used by the manager.

from  Manager
setContainer(Container $container)

Set the container instance used by the manager.

from  Manager
forgetDrivers()

Forget all of the resolved driver instances.

from  Manager
mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

string|null
resolveConnectionFromQueueRoute(object $queueable, UnitEnum|string|null $queue = null)

Resolve the default connection name for a given queueable instance.

string|null
resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

queueRoutes()

Get the queue routes manager instance.

queueRoutesContainer()

Get the container that owns the queue routes.

void
send(mixed $notifiables, mixed $notification)

Send the given notification to the given notifiable entities.

void
sendNow(mixed $notifiables, mixed $notification, array|null $channels = null)

Send the given notification immediately.

mixed
channel(UnitEnum|string|null $name = null)

Get a channel instance.

createDatabaseDriver()

Create an instance of the database driver.

createBroadcastDriver()

Create an instance of the broadcast driver.

createMailDriver()

Create an instance of the mail driver.

resolveNotificationSender()

Resolve the notification sender instance.

string
deliversVia()

Get the default channel driver name.

void
deliverVia(string $channel)

Set the default channel driver name.

locale(string $locale)

Set the locale of notifications.

string|null
getLocale()

Get the locale of notifications.

static void
flushState()

Flush all static state.

Details

protected Closure|null bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

Parameters

Closure $callback

Return Value

Closure|null

Exceptions

ReflectionException

in Manager at line 44
__construct(Container $container)

Create a new manager instance.

Parameters

Container $container

at line 145
string|null getDefaultDriver()

Get the default channel driver name.

Return Value

string|null

in Manager at line 60
mixed driver(UnitEnum|string|null $driver = null)

Get a driver instance.

Parameters

UnitEnum|string|null $driver

Return Value

mixed

Exceptions

InvalidArgumentException

at line 112
protected mixed createDriver(string $driver)

Create a new driver instance.

Parameters

string $driver

Return Value

mixed

Exceptions

InvalidArgumentException

in Manager at line 113
protected string|null getCreatorMethod(string $driver)

Get the name of the manager's creator method for the given driver.

Parameters

string $driver

Return Value

string|null

in Manager at line 124
protected mixed callCustomCreator(string $driver)

Call a custom driver creator.

Parameters

string $driver

Return Value

mixed

in Manager at line 140
Manager extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

Anonymous closures run in this manager's class scope; non-static closures also receive the manager as $this.

The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent driver resolution.

Parameters

string $driver
Closure $callback

Return Value

Manager

in Manager at line 160
array getDrivers()

Get all of the created "drivers".

Return Value

array

in Manager at line 168
Container getContainer()

Get the container instance used by the manager.

Return Value

Container

in Manager at line 182
Manager setContainer(Container $container)

Set the container instance used by the manager.

Swaps the singleton's container and configuration references; per-request use races across coroutines and breaks every concurrent driver resolution through this manager.

Parameters

Container $container

Return Value

Manager

in Manager at line 199
Manager forgetDrivers()

Forget all of the resolved driver instances.

Clears the singleton's driver cache; concurrent coroutines may already hold references that next resolution will not share.

Return Value

Manager

in Macroable at line 108
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 30
static void macro(string $name, callable|object $macro)

Register a custom macro.

Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 44
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 72
static void flushMacros()

Flush the existing macros.

Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 83
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

string|null resolveConnectionFromQueueRoute(object $queueable, UnitEnum|string|null $queue = null)

Resolve the default connection name for a given queueable instance.

Parameters

object $queueable
UnitEnum|string|null $queue

the caller-selected queue, overriding the queueable's queue when resolving a forwarded connection

Return Value

string|null

string|null resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

Parameters

object $queueable

Return Value

string|null

protected QueueRoutes queueRoutes()

Get the queue routes manager instance.

Return Value

QueueRoutes

at line 70
protected Container queueRoutesContainer()

Get the container that owns the queue routes.

Return Value

Container

at line 54
void send(mixed $notifiables, mixed $notification)

Send the given notification to the given notifiable entities.

Parameters

mixed $notifiables
mixed $notification

Return Value

void

at line 62
void sendNow(mixed $notifiables, mixed $notification, array|null $channels = null)

Send the given notification immediately.

Parameters

mixed $notifiables
mixed $notification
array|null $channels

Return Value

void

at line 78
mixed channel(UnitEnum|string|null $name = null)

Get a channel instance.

Parameters

UnitEnum|string|null $name

Return Value

mixed

at line 86
protected DatabaseChannel createDatabaseDriver()

Create an instance of the database driver.

Return Value

DatabaseChannel

at line 94
protected BroadcastChannel createBroadcastDriver()

Create an instance of the broadcast driver.

Return Value

BroadcastChannel

at line 102
protected MailChannel createMailDriver()

Create an instance of the mail driver.

Return Value

MailChannel

at line 128
protected NotificationSender resolveNotificationSender()

Resolve the notification sender instance.

Return Value

NotificationSender

at line 153
string deliversVia()

Get the default channel driver name.

Return Value

string

at line 161
void deliverVia(string $channel)

Set the default channel driver name.

Parameters

string $channel

Return Value

void

at line 177
ChannelManager locale(string $locale)

Set the locale of notifications.

Parameters

string $locale

Return Value

ChannelManager

at line 191
string|null getLocale()

Get the locale of notifications.

Return Value

string|null

at line 207
static void flushState()

Flush all static state.

Return Value

void