mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 15:07:47 +01:00
46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Flasher\Toastr\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 NotifyToastrExtension 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\Symfony\NotifyBundle] is not registered');
|
|
}
|
|
|
|
$configs = $container->getExtensionConfig($this->getAlias());
|
|
$config = $this->processConfiguration(new Configuration(), $configs);
|
|
|
|
$container->prependExtensionConfig('notify', array(
|
|
'adapters' => array(
|
|
'toastr' => $config,
|
|
),
|
|
));
|
|
}
|
|
}
|