Created
October 31, 2016 19:04
-
-
Save pboethig/1f6b0fd910ef625583af3e0f95ad1a26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Mittax\WsseBundle\DependencyInjection; | |
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use Symfony\Component\Config\FileLocator; | |
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; | |
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | |
use Symfony\Component\DependencyInjection\Loader; | |
use Symfony\Component\Yaml\Yaml; | |
/** | |
* This is the class that loads and manages your bundle configuration. | |
* | |
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html | |
*/ | |
class MittaxWsseExtension extends Extension implements PrependExtensionInterface, CompilerPassInterface | |
{ | |
/** | |
* @param ContainerBuilder $container | |
*/ | |
public function process(ContainerBuilder $container) | |
{ | |
// ... do something during the compilation | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function load(array $configs, ContainerBuilder $container) | |
{ | |
$configuration = new Configuration(); | |
$config = $this->processConfiguration($configuration, $configs); | |
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | |
$loader->load('services.yml'); | |
$container->setParameter('mittax.wsse.salt', $config['salt']); | |
} | |
public function prepend(ContainerBuilder $container) | |
{ | |
$config = Yaml::parse(file_get_contents(__DIR__.'/../Resources/config/config.yml')); | |
foreach ($config as $key => $configuration) { | |
$container->setParameter('mittax.wsse.salt', $configuration['salt']); | |
$container->prependExtensionConfig($key, $configuration); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment