|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* (c) Christian Gripp <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Core23\FacebookBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
17
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
18
|
|
|
|
|
19
|
|
|
final class Core23FacebookExtension extends Extension |
|
20
|
|
|
{ |
|
21
|
|
|
public function load(array $configs, ContainerBuilder $container): void |
|
22
|
|
|
{ |
|
23
|
|
|
$configuration = new Configuration(); |
|
24
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
25
|
|
|
$bundles = $container->getParameter('kernel.bundles'); |
|
26
|
|
|
|
|
27
|
|
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
28
|
|
|
$loader->load('action.xml'); |
|
29
|
|
|
$loader->load('services.xml'); |
|
30
|
|
|
|
|
31
|
|
|
if (isset($bundles['SonataBlockBundle'])) { |
|
32
|
|
|
$loader->load('block.xml'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
$this->configureApi($container, $config); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
private function configureApi(ContainerBuilder $container, array $config): void |
|
39
|
|
|
{ |
|
40
|
|
|
$container->setParameter('core23_facebook.api.app_id', $config['api']['app_id']); |
|
41
|
|
|
$container->setParameter('core23_facebook.api.app_secret', $config['api']['app_secret']); |
|
42
|
|
|
$container->setParameter('core23_facebook.api.permissions', $config['api']['permissions']); |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|