|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the FreshCentrifugoBundle. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Artem Henvald <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
declare(strict_types=1); |
|
12
|
|
|
|
|
13
|
|
|
namespace Fresh\CentrifugoBundle\DependencyInjection; |
|
14
|
|
|
|
|
15
|
|
|
use Fresh\CentrifugoBundle\Service\ChannelAuthenticator\ChannelAuthenticatorInterface; |
|
16
|
|
|
use Symfony\Component\Config\FileLocator; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
19
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* FreshCentrifugoExtension. |
|
23
|
|
|
* |
|
24
|
|
|
* @author Artem Henvald <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
class FreshCentrifugoExtension extends Extension |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritdoc} |
|
30
|
|
|
*/ |
|
31
|
|
|
public function load(array $configs, ContainerBuilder $container): void |
|
32
|
|
|
{ |
|
33
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
34
|
|
|
$loader->load('services.yaml'); |
|
35
|
|
|
|
|
36
|
|
|
$configuration = new Configuration(); |
|
37
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
38
|
|
|
$container->setParameter('centrifugo.channel_max_length', (int) $config['channel_max_length']); |
|
39
|
|
|
$container->setParameter('centrifugo.jwt.ttl', $config['jwt']['ttl']); |
|
40
|
|
|
$container->setParameter('centrifugo.fake_mode', $config['fake_mode']); |
|
41
|
|
|
$container->setParameter('centrifugo.api_key', $config['api_key']); |
|
42
|
|
|
$container->setParameter('centrifugo.api_endpoint', $config['api_endpoint']); |
|
43
|
|
|
$container->setParameter('centrifugo.secret', $config['secret']); |
|
44
|
|
|
$container->registerForAutoconfiguration(ChannelAuthenticatorInterface::class)->addTag('centrifugo.channel_authenticator'); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|