Skip to content

Instantly share code, notes, and snippets.

@pboethig
Created October 31, 2016 19:04
Show Gist options
  • Save pboethig/1f6b0fd910ef625583af3e0f95ad1a26 to your computer and use it in GitHub Desktop.
Save pboethig/1f6b0fd910ef625583af3e0f95ad1a26 to your computer and use it in GitHub Desktop.
<?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