|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
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 Sylius\Bundle\GridBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Processor; |
|
15
|
|
|
use Symfony\Component\Config\FileLocator; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
|
18
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class SyliusGridExtension extends Extension |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritdoc} |
|
27
|
|
|
*/ |
|
28
|
|
|
public function load(array $config, ContainerBuilder $container) |
|
29
|
|
|
{ |
|
30
|
|
|
$config = $this->processConfiguration($this->getConfiguration($config, $container), $config); |
|
31
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
32
|
|
|
|
|
33
|
|
|
$loader->load('services.xml'); |
|
34
|
|
|
$loader->load('filters.xml'); |
|
35
|
|
|
$loader->load('field_types.xml'); |
|
36
|
|
|
$loader->load('templating.xml'); |
|
37
|
|
|
$loader->load('twig.xml'); |
|
38
|
|
|
|
|
39
|
|
|
foreach (['filter', 'action'] as $templatesCollectionName) { |
|
40
|
|
|
$templates = isset($config['templates'][$templatesCollectionName]) ? $config['templates'][$templatesCollectionName] : []; |
|
41
|
|
|
$container->setParameter('sylius.grid.templates.'.$templatesCollectionName, $templates); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$container->setParameter('sylius.grids_definitions', $config['grids']); |
|
45
|
|
|
|
|
46
|
|
|
$container->setAlias('sylius.grid.renderer', 'sylius.grid.renderer.twig'); |
|
47
|
|
|
$container->setAlias('sylius.grid.data_extractor', 'sylius.grid.data_extractor.property_access'); |
|
48
|
|
|
|
|
49
|
|
|
foreach ($config['drivers'] as $enabledDriver) { |
|
50
|
|
|
$path = sprintf('driver/%s.xml', $enabledDriver); |
|
51
|
|
|
$loader->load($path); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|