1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* This file is part of phpFastCache. |
6
|
|
|
* |
7
|
|
|
* @license MIT License (MIT) |
8
|
|
|
* |
9
|
|
|
* For full copyright and license information, please see the docs/CREDITS.txt file. |
10
|
|
|
* |
11
|
|
|
* @author Georges.L (Geolim4) <[email protected]> |
12
|
|
|
* @author PastisD https://github.com/PastisD |
13
|
|
|
* @author Khoa Bui (khoaofgod) <[email protected]> http://www.phpfastcache.com |
14
|
|
|
* |
15
|
|
|
*/ |
16
|
|
|
declare(strict_types=1); |
17
|
|
|
|
18
|
|
|
namespace Phpfastcache\Bundle\DependencyInjection; |
19
|
|
|
|
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
21
|
|
|
use Symfony\Component\Config\FileLocator; |
22
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
23
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class phpFastCacheExtension |
27
|
|
|
* @package Phpfastcache\Bundle\DependencyInjection |
28
|
|
|
*/ |
29
|
|
|
class PhpfastcacheExtension extends Extension |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* {@inheritDoc} |
33
|
|
|
* |
34
|
|
|
* @throws \Exception |
35
|
|
|
* @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException |
36
|
|
|
* @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException |
37
|
|
|
* @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException |
38
|
|
|
*/ |
39
|
|
|
public function load(array $configs, ContainerBuilder $container) |
40
|
|
|
{ |
41
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
42
|
|
|
$loader->load('services.yml'); |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Includes services_dev.yml only |
46
|
|
|
* if we are in debug mode |
47
|
|
|
*/ |
48
|
|
|
if(\in_array($container->getParameter('kernel.environment'), ['dev', 'test'], true)){ |
49
|
|
|
$loader->load('services_dev.yml'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$configuration = new Configuration(); |
53
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
54
|
|
|
|
55
|
|
|
$container->setParameter('phpfastcache', $config); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|