-
Notifications
You must be signed in to change notification settings - Fork 5
/
Module.php
68 lines (57 loc) · 1.84 KB
/
Module.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace mkiselev\broadcasting;
use mkiselev\broadcasting\broadcasters\Broadcaster;
use mkiselev\broadcasting\components\BroadcastManager;
use yii\base\Application;
use yii\base\BootstrapInterface;
use yii\di\Instance;
use yii\web\UrlRule;
class Module extends \yii\base\Module implements BootstrapInterface
{
/** @var string Auth endpoint */
public $authEndpoint = 'broadcasting/auth';
/**
* @var string|array|\mkiselev\broadcasting\components\BroadcastManager
*/
public $broadcastManager = BroadcastManager::class;
/**
* @var string|array|\mkiselev\broadcasting\broadcasters\Broadcaster
*/
public $broadcaster;
/**
* @return \mkiselev\broadcasting\components\BroadcastManager|string
*/
public function getBroadcastManagerInstance()
{
if (!is_object($this->broadcastManager)) {
$this->broadcastManager = Instance::ensure($this->broadcastManager, BroadcastManager::class);
}
return $this->broadcastManager;
}
/**
* @return \mkiselev\broadcasting\broadcasters\Broadcaster|string
*/
public function getBroadcasterInstance()
{
if (!is_object($this->broadcaster)) {
$this->broadcaster = Instance::ensure($this->broadcaster, Broadcaster::class);
}
return $this->broadcaster;
}
/**
* Bootstrap method to be called during application bootstrap stage.
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app instanceof \yii\web\Application) {
$app->getUrlManager()->addRules([
[
'class' => UrlRule::class,
'pattern' => $this->authEndpoint,
'route' => $this->id . '/default/index',
],
]);
}
}
}