2018-11-21 11:13:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
2018-11-27 15:07:29 +00:00
|
|
|
namespace BeyondCode\LaravelWebSockets\WebSocket\Controllers;
|
2018-11-21 11:13:40 +00:00
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
2018-11-22 20:36:25 +00:00
|
|
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
2018-11-21 11:13:40 +00:00
|
|
|
|
2018-11-27 14:59:02 +00:00
|
|
|
class FetchChannel extends Controller
|
2018-11-21 11:13:40 +00:00
|
|
|
{
|
|
|
|
|
public function __invoke(Request $request)
|
|
|
|
|
{
|
2018-11-22 21:02:36 +00:00
|
|
|
$channel = $this->channelManager->find($request->appId, $request->channelName);
|
2018-11-22 17:13:43 +00:00
|
|
|
|
2018-11-22 21:02:36 +00:00
|
|
|
if (is_null($channel)) {
|
2018-11-26 22:52:01 +00:00
|
|
|
throw new HttpException(404, "Unknown channel `{$request->channelName}`.");
|
2018-11-21 14:42:04 +00:00
|
|
|
}
|
2018-11-21 23:12:23 +00:00
|
|
|
|
2018-11-22 21:02:36 +00:00
|
|
|
return $channel->toArray();
|
2018-11-21 11:13:40 +00:00
|
|
|
}
|
|
|
|
|
}
|