|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the ONGR package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) NFQ Technologies UAB <[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 ONGR\FilterManagerBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use ONGR\FilterManagerBundle\DependencyInjection\Filter\AbstractFilterFactory; |
|
15
|
|
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17
|
|
|
use Symfony\Component\Config\FileLocator; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
20
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
21
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* This is the class that loads and manages bundle configuration. |
|
25
|
|
|
*/ |
|
26
|
|
|
class ONGRFilterManagerExtension extends Extension |
|
27
|
|
|
{ |
|
28
|
|
|
|
|
29
|
|
|
const PREFIX = 'ongr_filter_manager'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritdoc} |
|
33
|
|
|
*/ |
|
34
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
35
|
|
|
{ |
|
36
|
|
|
$configuration = new Configuration(); |
|
37
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
38
|
|
|
|
|
39
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
40
|
|
|
$loader->load('services.yml'); |
|
41
|
|
|
|
|
42
|
|
|
$container->setParameter('ongr_filter_manager.filters', $config['filters']); |
|
43
|
|
|
$container->setParameter('ongr_filter_manager.managers', $config['managers']); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Formats filter service id from given name. |
|
48
|
|
|
* |
|
49
|
|
|
* @param string $name Filter name. |
|
50
|
|
|
* |
|
51
|
|
|
* @return string |
|
52
|
|
|
*/ |
|
53
|
|
|
public static function getFilterId($name) |
|
54
|
|
|
{ |
|
55
|
|
|
return sprintf(self::PREFIX.'.filter.%s', $name); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Formats filter manager service id from given name. |
|
60
|
|
|
* |
|
61
|
|
|
* @param string $name Filter manager name. |
|
62
|
|
|
* |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
|
|
public static function getFilterManagerId($name = 'default') |
|
66
|
|
|
{ |
|
67
|
|
|
return sprintf(self::PREFIX.'.manager.%s', $name); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|