1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dontdrinkandroot\Gitki\WebBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
8
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
9
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
10
|
|
|
|
11
|
|
|
class DdrGitkiWebExtension extends Extension implements PrependExtensionInterface |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* {@inheritdoc} |
15
|
|
|
*/ |
16
|
|
|
public function load(array $configs, ContainerBuilder $container) |
17
|
|
|
{ |
18
|
|
|
$configuration = new Configuration(); |
19
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
20
|
|
|
|
21
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
22
|
|
|
$loader->load('services.yml'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
|
|
public function prepend(ContainerBuilder $container) |
29
|
|
|
{ |
30
|
|
|
$configs = $container->getExtensionConfig($this->getAlias()); |
31
|
|
|
$configuration = $this->getConfiguration($configs, $container); |
32
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$hwiOauthConfig = [ |
35
|
|
|
'resource_owners' => [] |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
// $securityConfig = [ |
39
|
|
|
// 'firewalls' => [ |
40
|
|
|
// 'secured_area' => [ |
41
|
|
|
// 'oauth' => [ |
42
|
|
|
// 'resource_owners' => [] |
43
|
|
|
// ] |
44
|
|
|
// ] |
45
|
|
|
// ] |
46
|
|
|
// ]; |
47
|
|
|
|
48
|
|
|
// if (isset($config['authentication']['oauth']['default_provider'])) { |
49
|
|
|
// $securityConfig['firewalls']['secured_area']['oauth']['login_path'] = |
50
|
|
|
// '/connect/' . $config['authentication']['oauth']['default_provider']; |
51
|
|
|
// } else { |
52
|
|
|
// $securityConfig['firewalls']['secured_area']['oauth']['login_path'] = '/login'; |
53
|
|
|
// } |
54
|
|
|
|
55
|
|
|
$formLoginEnabled = true; |
56
|
|
|
if (isset($config['authentication']['form_login_enabled'])) { |
57
|
|
|
$formLoginEnabled = $config['authentication']['form_login_enabled']; |
58
|
|
|
} |
59
|
|
|
$twigConfig['globals']['ddr_gitki_form_login_enabled'] = $formLoginEnabled; |
|
|
|
|
60
|
|
|
|
61
|
|
|
if (isset($config['authentication']['oauth']['providers']['github'])) { |
62
|
|
|
$githubConfig = $config['authentication']['oauth']['providers']['github']; |
63
|
|
|
$hwiOauthConfig['fosub']['properties']['github'] = 'githubId'; |
64
|
|
|
$hwiOauthConfig['resource_owners']['github'] = [ |
65
|
|
|
'type' => 'github', |
66
|
|
|
'client_id' => $githubConfig['client_id'], |
67
|
|
|
'client_secret' => $githubConfig['secret'], |
68
|
|
|
'scope' => 'user:email' |
69
|
|
|
]; |
70
|
|
|
// $securityConfig['firewalls']['secured_area']['oauth']['resource_owners']['github'] = '/login/check-github'; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
if (isset($config['authentication']['oauth']['providers']['google'])) { |
74
|
|
|
$googleConfig = $config['authentication']['oauth']['providers']['google']; |
75
|
|
|
$hwiOauthConfig['fosub']['properties']['google'] = 'googleId'; |
76
|
|
|
$hwiOauthConfig['resource_owners']['google'] = [ |
77
|
|
|
'type' => 'google', |
78
|
|
|
'client_id' => $googleConfig['client_id'], |
79
|
|
|
'client_secret' => $googleConfig['secret'], |
80
|
|
|
'scope' => 'email profile', |
81
|
|
|
'options' => [ |
82
|
|
|
'access_type' => 'online', |
83
|
|
|
'approval_prompt' => 'auto', |
84
|
|
|
'display' => 'page', |
85
|
|
|
'login_hint' => 'email address' |
86
|
|
|
] |
87
|
|
|
]; |
88
|
|
|
// $securityConfig['firewalls']['secured_area']['oauth']['resource_owners']['google'] = '/login/check-google'; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
// $container->prependExtensionConfig('security', $securityConfig); |
92
|
|
|
$container->prependExtensionConfig('hwi_oauth', $hwiOauthConfig); |
93
|
|
|
$container->prependExtensionConfig('twig', $twigConfig); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
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: