|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the bugloos/responder-bundle project. |
|
5
|
|
|
* (c) Bugloos <https://bugloos.com/> |
|
6
|
|
|
* For the full copyright and license information, please view |
|
7
|
|
|
* the LICENSE file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Bugloos\ResponderBundle\DependencyInjection; |
|
11
|
|
|
|
|
12
|
|
|
use Symfony\Component\Config\FileLocator; |
|
13
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
14
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
15
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author Mojtaba Gheytasi <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class ResponderExtension extends Extension |
|
21
|
|
|
{ |
|
22
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
23
|
|
|
{ |
|
24
|
|
|
$configuration = $this->getConfiguration($configs, $container); |
|
25
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
$container->setParameter('default_max_items_per_page', $config['default_max_items_per_page']); |
|
28
|
|
|
$container->setParameter('default_items_per_page', $config['default_items_per_page']); |
|
29
|
|
|
$container->setParameter('page_key_in_request', $config['page_key_in_request']); |
|
30
|
|
|
$container->setParameter('items_per_page_key_in_request', $config['items_per_page_key_in_request']); |
|
31
|
|
|
|
|
32
|
|
|
$container->setAlias( |
|
33
|
|
|
'paginator_response', |
|
34
|
|
|
$config['paginator_response'] |
|
35
|
|
|
)->setPublic(true); |
|
36
|
|
|
|
|
37
|
|
|
$loader = new YamlFileLoader( |
|
38
|
|
|
$container, |
|
39
|
|
|
new FileLocator(__DIR__.'/../Resources/config') |
|
40
|
|
|
); |
|
41
|
|
|
|
|
42
|
|
|
$loader->load('services.yaml'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getAlias(): string |
|
46
|
|
|
{ |
|
47
|
|
|
return 'bugloos_responder'; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|