-
-
Notifications
You must be signed in to change notification settings - Fork 112
/
DataTablesExtension.php
71 lines (61 loc) · 2.31 KB
/
DataTablesExtension.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
* Symfony DataTables Bundle
* (c) Omines Internetbureau B.V. - https://omines.nl/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Omines\DataTablesBundle\DependencyInjection;
use Omines\DataTablesBundle\Adapter\AdapterInterface;
use Omines\DataTablesBundle\Column\AbstractColumn;
use Omines\DataTablesBundle\DataTableTypeInterface;
use Omines\DataTablesBundle\Exporter\DataTableExporterInterface;
use Omines\DataTablesBundle\Filter\AbstractFilter;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
* DataTablesExtension.
*
* @author Niels Keurentjes <niels.keurentjes@omines.com>
*/
class DataTablesExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$container->setAlias('datatables.renderer', $config['renderer']);
unset($config['renderer']);
$container->setParameter('datatables.config', $config);
$container->registerForAutoconfiguration(AbstractColumn::class)
->addTag('datatables.column')
->setShared(false);
$container->registerForAutoconfiguration(AbstractFilter::class)
->addTag('datatables.filter')
->setShared(false);
$container->registerForAutoconfiguration(AdapterInterface::class)
->addTag('datatables.adapter')
->setShared(false);
$container->registerForAutoconfiguration(DataTableTypeInterface::class)
->addTag('datatables.type');
$container->registerForAutoconfiguration(DataTableExporterInterface::class)
->addTag('datatables.exporter');
}
/**
* @return string
*/
public function getAlias()
{
// Default would underscore the camelcase unintuitively
return 'datatables';
}
}