1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Azine\HybridAuthBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
8
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* This is the class that loads and manages your bundle configuration. |
12
|
|
|
* |
13
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
14
|
|
|
*/ |
15
|
|
|
class AzineHybridAuthExtension extends Extension |
16
|
|
|
{ |
17
|
|
|
const PREFIX = 'azine_hybrid_auth'; |
18
|
|
|
const ENDPOINT_ROUTE = 'endpoint_route'; |
19
|
|
|
const BASE_URL = 'base_url'; |
20
|
|
|
const DEBUG = 'debug'; |
21
|
|
|
const DEBUG_FILE = 'debug_file'; |
22
|
|
|
const PROVIDERS = 'providers'; |
23
|
|
|
const PROVIDER_NAME = 'name'; |
24
|
|
|
const ENABLED = 'enabled'; |
25
|
|
|
const SCOPE = 'scope'; |
26
|
|
|
const KEYS = 'keys'; |
27
|
|
|
const ID = 'id'; |
28
|
|
|
const KEY = 'key'; |
29
|
|
|
const SECRET = 'secret'; |
30
|
|
|
const WRAPPER = 'wrapper'; |
31
|
|
|
const WRAPPER_PATH = 'path'; |
32
|
|
|
const WRAPPER_CLASS = 'class'; |
33
|
|
|
const SORTER = 'contact_sorter'; |
34
|
|
|
const MERGER = 'contact_merger'; |
35
|
|
|
const FILTER = 'contact_filter'; |
36
|
|
|
const GENDER_GUESSER = 'gender_guesser'; |
37
|
|
|
const STORE_FOR_USER = 'store_for_user'; |
38
|
|
|
const STORE_AS_COOKIE = 'store_as_cookie'; |
39
|
|
|
const EXPIRES_IN_DAYS = 'expires_in_days'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public function load(array $configs, ContainerBuilder $container) |
45
|
|
|
{ |
46
|
|
|
$configuration = new Configuration(); |
47
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
48
|
|
|
|
49
|
|
|
$container->setParameter(self::PREFIX.'_'.self::ENDPOINT_ROUTE, $config[self::ENDPOINT_ROUTE]); |
50
|
|
|
$container->setParameter(self::PREFIX.'_'.self::DEBUG, $config[self::DEBUG]); |
51
|
|
|
$container->setParameter(self::PREFIX.'_'.self::DEBUG_FILE, $config[self::DEBUG_FILE]); |
52
|
|
|
|
53
|
|
|
// workaround for hybridauth/hybridauth inconsistency between OAuth1 and OAuth2 clients |
54
|
|
|
foreach ($config[self::PROVIDERS] as $providerName => $providerConfig){ |
55
|
|
|
$config[self::PROVIDERS][$providerName][self::KEYS][self::ID] = $providerConfig[self::KEYS][self::KEY]; |
56
|
|
|
} |
57
|
|
|
$container->setParameter(self::PREFIX.'_'.self::PROVIDERS, $config[self::PROVIDERS]); |
58
|
|
|
$container->setParameter(self::PREFIX.'_'.self::STORE_FOR_USER, $config[self::STORE_FOR_USER]); |
59
|
|
|
$container->setParameter(self::PREFIX.'_'.self::STORE_AS_COOKIE, $config[self::STORE_AS_COOKIE]); |
60
|
|
|
$container->setParameter(self::PREFIX.'_'.self::EXPIRES_IN_DAYS, $config[self::EXPIRES_IN_DAYS]); |
61
|
|
|
|
62
|
|
|
$container->setAlias(self::PREFIX.'_'.self::FILTER, $config[self::FILTER]); |
63
|
|
|
$container->setAlias(self::PREFIX.'_'.self::MERGER, $config[self::MERGER]); |
64
|
|
|
$container->setAlias(self::PREFIX.'_'.self::SORTER, $config[self::SORTER]); |
65
|
|
|
$container->setAlias(self::PREFIX.'_'.self::GENDER_GUESSER, $config[self::GENDER_GUESSER]); |
66
|
|
|
|
67
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
68
|
|
|
$loader->load('services.yml'); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|