/
WebsocketsBootloader.php
41 lines (36 loc) · 1.22 KB
/
WebsocketsBootloader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
namespace Spiral\Broadcasting\Bootloader;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Spiral\Boot\Bootloader\Bootloader;
use Spiral\Bootloader\Http\HttpBootloader;
use Spiral\Broadcasting\BroadcastInterface;
use Spiral\Broadcasting\Config\BroadcastConfig;
use Spiral\Broadcasting\Middleware\AuthorizationMiddleware;
use Spiral\Core\Attribute\Singleton;
use Spiral\Core\BinderInterface;
#[Singleton]
final class WebsocketsBootloader extends Bootloader
{
protected const DEPENDENCIES = [
HttpBootloader::class,
BroadcastingBootloader::class,
];
public function boot(BinderInterface $binder): void
{
$binder->bindSingleton(AuthorizationMiddleware::class, static function (
BroadcastInterface $broadcast,
ResponseFactoryInterface $responseFactory,
BroadcastConfig $config,
?EventDispatcherInterface $dispatcher = null
): AuthorizationMiddleware {
return new AuthorizationMiddleware(
$broadcast,
$responseFactory,
$config->getAuthorizationPath(),
$dispatcher
);
});
}
}