|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2023 |
|
6
|
|
|
* @package symfony |
|
7
|
|
|
* @subpackage DependencyInjection |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\ShopBundle\DependencyInjection; |
|
12
|
|
|
|
|
13
|
|
|
use Symfony\Component\Yaml\Yaml; |
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
16
|
|
|
use Symfony\Component\Config\Resource\FileResource; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* This is the class that loads and manages your bundle configuration |
|
24
|
|
|
* |
|
25
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
|
26
|
|
|
* @package symfony |
|
27
|
|
|
* @subpackage DependencyInjection |
|
28
|
|
|
*/ |
|
29
|
|
|
final class AimeosShopExtension extends Extension implements PrependExtensionInterface |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritDoc} |
|
33
|
|
|
*/ |
|
34
|
|
|
public function load( array $configs, ContainerBuilder $container ) |
|
35
|
|
|
{ |
|
36
|
|
|
$configuration = new Configuration(); |
|
37
|
|
|
$config = $this->processConfiguration( $configuration, $configs ); |
|
38
|
|
|
|
|
39
|
|
|
foreach( $configs as $list ) { |
|
40
|
|
|
$config = array_replace_recursive( $config, $list ); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
foreach( $config as $key => $value ) { |
|
44
|
|
|
$container->setParameter( 'aimeos_shop.' . $key, $value ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$loader = new Loader\YamlFileLoader( $container, new FileLocator( dirname( __DIR__, 2 ) . '/config' ) ); |
|
48
|
|
|
$loader->load( 'services.yaml' ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Allows an extension to prepend the extension configurations. |
|
54
|
|
|
* |
|
55
|
|
|
* @param ContainerBuilder $container ContainerBuilder object |
|
56
|
|
|
*/ |
|
57
|
|
|
public function prepend( ContainerBuilder $container ) |
|
58
|
|
|
{ |
|
59
|
|
|
$configFile = dirname( __DIR__, 2 ) . '/config/aimeos_shop.yaml'; |
|
60
|
|
|
$config = Yaml::parse( file_get_contents( $configFile ) ); |
|
61
|
|
|
|
|
62
|
|
|
$container->prependExtensionConfig( 'aimeos_shop', $config ); |
|
63
|
|
|
$container->addResource( new FileResource( $configFile ) ); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|