Skip to content

Commit

Permalink
complete broadcaster
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu Shing committed Nov 15, 2024
1 parent 65696e9 commit 76fa551
Show file tree
Hide file tree
Showing 2 changed files with 283 additions and 237 deletions.
12 changes: 9 additions & 3 deletions src/broadcasting/src/Broadcasters/Broadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public function resolveAuthenticatedUser(RequestInterface $request): ?array
if ($this->authenticatedUserCallback) {
return $this->authenticatedUserCallback->__invoke($request);
}

return null;
}

/**
Expand Down Expand Up @@ -247,7 +249,8 @@ protected function binder()
// DOTO: 實作 \Illuminate\Contracts\Routing\BindingRegistrar
// if (! $this->bindingRegistrar) {
// $this->bindingRegistrar = ApplicationContext::getContainer()->has(BindingRegistrar::class)
// ? ApplicationContext::getContainer()->get(BindingRegistrar::class) : null;
// ? ApplicationContext::getContainer()->get(BindingRegistrar::class)
// : null;
// }
//
// return $this->bindingRegistrar;
Expand Down Expand Up @@ -283,10 +286,13 @@ protected function retrieveUser(string $channel): mixed
}

foreach (Arr::wrap($guards) as $guard) {
if ($user = Auth::guard($guard)->user()) {
$user = Auth::guard($guard)->user();
if ($user) {
return $user;
}
}

return null;
}

/**
Expand All @@ -310,7 +316,7 @@ protected function retrieveChannelOptions(string $channel): array
*/
protected function channelNameMatchesPattern(string $channel, string $pattern): bool
{
return preg_match('/^'.preg_replace('/\{(.*?)\}/', '([^\.]+)', $pattern).'$/', $channel);
return (bool) preg_match('/^'.preg_replace('/\{(.*?)\}/', '([^\.]+)', $pattern).'$/', $channel);
}

/**
Expand Down
Loading

0 comments on commit 76fa551

Please sign in to comment.