1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys PackBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\PackBundle\DependencyInjection
;
14 use Rapsys\PackBundle\RapsysPackBundle
;
16 use Symfony\Component\DependencyInjection\ContainerBuilder
;
17 use Symfony\Component\DependencyInjection\Extension\Extension
;
20 * This is the class that loads and manages your bundle configuration.
22 * @link http://symfony.com/doc/current/cookbook/bundles/extension.html
26 class RapsysPackExtension
extends Extension
{
30 public function load(array $configs, ContainerBuilder
$container): void {
32 $configuration = $this->getConfiguration($configs, $container);
34 //Process the configuration to get merged config
35 $config = $this->processConfiguration($configuration, $configs);
38 $alias = RapsysPackBundle
::getAlias();
40 //Detect when no user configuration is provided
41 if ($configs === [[]]) {
42 //Prepend default config
43 $container->prependExtensionConfig($alias, $config);
46 //Save configuration in parameters
47 $container->setParameter($alias, $config);
49 //Set rapsyspack.alias key
50 $container->setParameter($alias.'.alias', $alias);
52 //Set rapsyspack.cache key
53 $container->setParameter($alias.'.cache', $config['cache']);
55 //Set rapsyspack.public key
56 $container->setParameter($alias.'.public', $config['public']);
58 //Set rapsyspack.version key
59 $container->setParameter($alias.'.version', RapsysPackBundle
::getVersion());
65 * @xxx Required by kernel to load renamed alias configuration
67 public function getAlias(): string {
68 return RapsysPackBundle
::getAlias();