[13.x] Add enum support to ChannelManager#59716
Closed
sumaiazaman wants to merge 2 commits into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds enum support to
ChannelManager::channel()andChannelManager::deliverVia()using theenum_value()helper, aligning it with other manager classes that already support this pattern.Context
Several manager classes already accept enums for connection/driver names:
Manager::driver()CacheManager::store()AuthManager::guard()MailManager::mailer()QueueManager::connection()LogManager::channel()FilesystemManager::disk()RedisManager::connection()ChannelManager::channel()ChannelManager::deliverVia()This inconsistency means developers who define notification channel names as enums cannot pass them directly to
Notification::channel()like they can withQueue::connection()orCache::store(). More importantly, passing an enum todeliverVia()silently stores the enum object in$defaultChannelinstead of its string value, causing a mismatch when the value is later used as a driver key.Solution
@paramdocblock onchannel()to accept\UnitEnum|string|null— the parentManager::driver()already callsenum_value(), so no logic change is needed hereenum_value()call indeliverVia()to ensure the string value is stored in$defaultChannel@paramdocblock ondeliverVia()to accept\UnitEnum|stringExample
Why This Doesn't Break Existing Features
enum_value()returns the input unchanged for strings andnull— all existing calls behave identicallychannel()change is docblock-only; the underlyingManager::driver()already handles enum resolutionCacheManager,AuthManager,MailManager,QueueManager,LogManager,FilesystemManager,RedisManager, and the baseManagerclassChanges
src/Illuminate/Notifications/ChannelManager.php— Addedenum_value()indeliverVia(); updated docblocks onchannel()anddeliverVia()tests/Notifications/NotificationChannelManagerTest.php— Added 2 test casesTest Plan
testChannelManagerCanResolveBackedEnumChannel— Verifies backed enum resolves to the correct channel drivertestDeliverViaAcceptsBackedEnum— Verifies the string value is stored in$defaultChannel, not the enum object