/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
src/Illuminate/Notifications/ChannelManager.php
192 строки
5 KB
yousef kadah
[13.x] Add enum support to NotificationChannelManager channel and driver methods (#59783)
21 апр 2026, 15:41
Не верифицирован
21 апр 2026, 15:41
95891fa
Код
Авторство
О чём код?
<?php namespace Illuminate\Notifications; use Illuminate\Contracts\Bus\Dispatcher as Bus; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Notifications\Dispatcher as DispatcherContract; use Illuminate\Contracts\Notifications\Factory as FactoryContract; use Illuminate\Support\Manager; use Illuminate\Support\Queue\Concerns\ResolvesQueueRoutes; use Illuminate\Support\Traits\Macroable; use InvalidArgumentException; class ChannelManager extends Manager implements DispatcherContract, FactoryContract { use Macroable, ResolvesQueueRoutes; /** * The resolved notification sender instance. * * @var \Illuminate\Notifications\NotificationSender|null */ protected $notificationSender; /** * The default channel used to deliver messages. * * @var string */ protected $defaultChannel = 'mail'; /** * The locale used when sending notifications. * * @var string|null */ protected $locale; /** * Send the given notification to the given notifiable entities. * * @param \Illuminate\Support\Collection|mixed $notifiables * @param mixed $notification * @return void */ public function send($notifiables, $notification) { $this->resolveNotificationSender()->send($notifiables, $notification); } /** * Send the given notification immediately. * * @param \Illuminate\Support\Collection|mixed $notifiables * @param mixed $notification * @param array|null $channels * @return void */ public function sendNow($notifiables, $notification, ?array $channels = null) { $this->resolveNotificationSender()->sendNow($notifiables, $notification, $channels); } /** * Get a channel instance. * * @param \UnitEnum|string|null $name * @return mixed */ public function channel($name = null) { return $this->driver($name); } /** * Get a driver instance. * * @param \UnitEnum|string|null $driver * @return mixed */ public function driver($driver = null) { return parent::driver($driver); } /** * Create an instance of the database driver. * * @return \Illuminate\Notifications\Channels\DatabaseChannel */ protected function createDatabaseDriver() { return $this->container->make(Channels\DatabaseChannel::class); } /** * Create an instance of the broadcast driver. * * @return \Illuminate\Notifications\Channels\BroadcastChannel */ protected function createBroadcastDriver() { return $this->container->make(Channels\BroadcastChannel::class); } /** * Create an instance of the mail driver. * * @return \Illuminate\Notifications\Channels\MailChannel */ protected function createMailDriver() { return $this->container->make(Channels\MailChannel::class); } /** * Create a new driver instance. * * @param string $driver * @return mixed * * @throws \InvalidArgumentException */ protected function createDriver($driver) { try { return parent::createDriver($driver); } catch (InvalidArgumentException $e) { if (class_exists($driver)) { return $this->container->make($driver); } throw $e; } } /** * Resolve the NotificationSender instance. * * @return \Illuminate\Notifications\NotificationSender */ protected function resolveNotificationSender() { return $this->notificationSender ??= new NotificationSender( $this, $this->container->make(Bus::class), $this->container->make(Dispatcher::class), $this->locale ); } /** * Get the default channel driver name. * * @return string */ public function getDefaultDriver() { return $this->defaultChannel; } /** * Get the default channel driver name. * * @return string */ public function deliversVia() { return $this->getDefaultDriver(); } /** * Set the default channel driver name. * * @param string $channel * @return void */ public function deliverVia($channel) { $this->defaultChannel = $channel; } /** * Set the locale of notifications. * * @param string $locale * @return $this */ public function locale($locale) { $this->locale = $locale; return $this; } }