]>
Commit | Line | Data |
---|---|---|
23ff8d36 JB |
1 | <?php |
2 | ||
3 | namespace Wallabag\UserBundle\DependencyInjection; | |
4 | ||
23ff8d36 | 5 | use Symfony\Component\Config\FileLocator; |
f808b016 | 6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
23ff8d36 | 7 | use Symfony\Component\DependencyInjection\Loader; |
f808b016 | 8 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
3b68f6ca | 9 | use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
23ff8d36 | 10 | |
3b68f6ca | 11 | class WallabagUserExtension extends Extension implements PrependExtensionInterface |
23ff8d36 | 12 | { |
3b68f6ca IB |
13 | public function prepend(ContainerBuilder $container) |
14 | { | |
15 | $ldap = $container->getParameter('ldap_enabled'); | |
16 | ||
17 | if ($ldap) { | |
18 | $container->prependExtensionConfig('security', array( | |
19 | 'providers' => array( | |
20 | 'chain_provider' => array(), | |
21 | ), | |
22 | )); | |
23 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | |
24 | $loader->load('ldap.yml'); | |
25 | } elseif ($container->hasExtension('fr3d_ldap')) { | |
26 | $container->prependExtensionConfig('fr3_d_ldap', array( | |
27 | 'driver' => array( | |
28 | 'host' => 'localhost', | |
29 | ), | |
30 | 'user' => array( | |
31 | 'baseDn' => 'dc=example,dc=com', | |
32 | ), | |
33 | )); | |
34 | } | |
35 | } | |
36 | ||
23ff8d36 JB |
37 | public function load(array $configs, ContainerBuilder $container) |
38 | { | |
39 | $configuration = new Configuration(); | |
40 | $config = $this->processConfiguration($configuration, $configs); | |
41 | ||
f808b016 | 42 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
23ff8d36 | 43 | $loader->load('services.yml'); |
3b68f6ca IB |
44 | if ($container->getParameter('ldap_enabled')) { |
45 | $loader->load('ldap_services.yml'); | |
46 | } | |
de3d716a | 47 | $container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']); |
23ff8d36 JB |
48 | } |
49 | ||
50 | public function getAlias() | |
51 | { | |
52 | return 'wallabag_user'; | |
53 | } | |
54 | } |