Skip to content

Commit 0e48980

Browse files
authored
Merge pull request #9 from makoso/develop
Feature - allow save filters in session
2 parents 42f3c42 + 59fbe7d commit 0e48980

File tree

5 files changed

+144
-79
lines changed

5 files changed

+144
-79
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Makoso\DatagridBundle\DependencyInjection;
4+
5+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6+
use Symfony\Component\Config\Definition\ConfigurationInterface;
7+
8+
final class Configuration implements ConfigurationInterface
9+
{
10+
public function getConfigTreeBuilder()
11+
{
12+
$treeBuilder = new TreeBuilder('makoso_datagrid');
13+
14+
$treeBuilder
15+
->getRootNode()
16+
->children()
17+
->booleanNode('save_filters_in_session')->defaultFalse()->end()
18+
->end()
19+
->end()
20+
;
21+
22+
return $treeBuilder;
23+
}
24+
}
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
<?php
2-
/**
3-
* Created by Krzysztof Makowski <kontakt@krzysztof-makowski.pl>.
4-
* Project: EMagic
5-
* Date: 29.11.17
6-
* Time: 21:35
7-
*/
82

93
namespace Makoso\DatagridBundle\DependencyInjection;
104

@@ -13,15 +7,27 @@
137
use Symfony\Component\DependencyInjection\Loader;
148
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
159

16-
1710
class MakosoDatagridExtension extends Extension
1811
{
19-
/**
20-
* {@inheritdoc}
21-
*/
12+
2213
public function load(array $configs, ContainerBuilder $container)
2314
{
24-
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
15+
$configuration = new Configuration();
16+
$config = $this->processConfiguration($configuration, $configs);
17+
$this->setConfigurationToContainer('makoso_datagrid.', $config, $container);
18+
19+
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
2520
$loader->load('services.yaml');
2621
}
22+
23+
private function setConfigurationToContainer(string $prefix, array $config, ContainerBuilder $container): void
24+
{
25+
foreach ($config as $key => $value) {
26+
if (is_array($value)) {
27+
$this->setConfigurationToContainer($prefix . $key . '.', $value, $container);
28+
} else {
29+
$container->setParameter($prefix . $key, $value);
30+
}
31+
}
32+
}
2733
}

0 commit comments

Comments
 (0)