Skip to content

Commit

Permalink
support shorter subscription syntax (#38408)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell authored Aug 16, 2021
1 parent 4caba8b commit 9bfe672
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Illuminate/Events/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,13 @@ public function subscribe($subscriber)

if (is_array($events)) {
foreach ($events as $event => $listeners) {
foreach ($listeners as $listener) {
foreach (Arr::wrap($listeners) as $listener) {
if (is_string($listener) && method_exists($subscriber, $listener)) {
$this->listen($event, [get_class($subscriber), $listener]);

continue;
}

$this->listen($event, $listener);
}
}
Expand Down

0 comments on commit 9bfe672

Please sign in to comment.