1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yokai\SecurityTokenBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
6
|
|
|
use Symfony\Component\Config\FileLocator; |
7
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
8
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
9
|
|
|
use Yokai\SecurityTokenBundle\DependencyInjection\Factory\TokenConfigurationFactory; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @author Yann Eugoné <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class YokaiSecurityTokenExtension extends Extension |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @inheritdoc |
18
|
|
|
*/ |
19
|
4 |
|
public function load(array $configs, ContainerBuilder $container) |
20
|
|
|
{ |
21
|
4 |
|
$config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs); |
|
|
|
|
22
|
|
|
|
23
|
4 |
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
24
|
4 |
|
$loader->load('services.xml'); |
25
|
|
|
|
26
|
4 |
|
$this->registerTokens($config, $container); |
27
|
4 |
|
$this->registerAliases($config, $container); |
28
|
4 |
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param array $config |
32
|
|
|
* @param ContainerBuilder $container |
33
|
|
|
*/ |
34
|
4 |
|
private function registerTokens(array $config, ContainerBuilder $container) |
35
|
|
|
{ |
36
|
4 |
|
foreach ($config['tokens'] as $name => $token) { |
37
|
3 |
|
TokenConfigurationFactory::create( |
38
|
|
|
$name, |
39
|
3 |
|
$token['generator'], |
40
|
3 |
|
$token['duration'], |
41
|
3 |
|
$token['usages'], |
42
|
3 |
|
$token['keep'], |
43
|
3 |
|
$container |
44
|
|
|
); |
45
|
|
|
} |
46
|
4 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param array $config |
50
|
|
|
* @param ContainerBuilder $container |
51
|
|
|
*/ |
52
|
4 |
|
private function registerAliases(array $config, ContainerBuilder $container) |
53
|
|
|
{ |
54
|
4 |
|
foreach ($config['services'] as $name => $service) { |
55
|
4 |
|
$container->setAlias(sprintf('yokai_security_token.%s', $name), $service); |
56
|
|
|
} |
57
|
4 |
|
} |
58
|
|
|
} |
59
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: