Files
php-flasher/DependencyInjection/NotifyNotyfExtension.php
T
KHOUBZA Younes 99d083b005 update namespace
2020-12-03 09:15:47 +01:00

48 lines
1.5 KiB
PHP

<?php
namespace Flasher\Notyf\Symfony\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
final class NotifyNotyfExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*
* @throws \Exception
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');
$configuration = new Configuration();
$this->processConfiguration($configuration, $configs);
}
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
if (!$container->hasExtension('notify')) {
throw new \RuntimeException('[Flasher\SymfonyFlasher\PrimeBundle] is not registered');
}
$configs = $container->getExtensionConfig($this->getAlias());
$config = $this->processConfiguration(new Configuration(), $configs);
$notifyConfig = $container->getExtensionConfig('notify');
$container->prependExtensionConfig('notify', array(
'adapters' => array(
'notyf' => $config,
),
));
}
}