|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* AJGL CSV Bundle |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (C) Antonio J. García Lagar <[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 Ajgl\Bundle\CsvBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
17
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @author Antonio J. García Lagar <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class AjglCsvExtension extends Extension |
|
23
|
|
|
{ |
|
24
|
1 |
|
public function load(array $config, ContainerBuilder $container) |
|
25
|
|
|
{ |
|
26
|
1 |
|
$configuration = new Configuration(); |
|
27
|
1 |
|
$config = $this->processConfiguration($configuration, $config); |
|
28
|
|
|
|
|
29
|
1 |
|
$container->setParameter('ajgl_csv.reader.default_type', $config['reader_default_type']); |
|
30
|
1 |
|
$container->setParameter('ajgl_csv.writer.default_type', $config['writer_default_type']); |
|
31
|
|
|
|
|
32
|
1 |
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
33
|
1 |
|
if (method_exists('Symfony\Component\DependencyInjection\Definition', 'getFactoryClass')) { |
|
34
|
1 |
|
$loader->load('csv.legacy.xml'); |
|
35
|
1 |
|
} else { |
|
36
|
|
|
$loader->load('csv.xml'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
1 |
|
$csvDefinition = $container->getDefinition('ajgl_csv'); |
|
40
|
1 |
|
$csvDefinition->addMethodCall('setDefaultReaderType', array('%ajgl_csv.reader.default_type%')); |
|
41
|
1 |
|
$csvDefinition->addMethodCall('setDefaultWriterType', array('%ajgl_csv.writer.default_type%')); |
|
42
|
1 |
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|