<?php declare(strict_types=1);
namespace Shopware\Elasticsearch;
use Shopware\Core\Framework\Bundle;
use Shopware\Core\Kernel;
use Shopware\Elasticsearch\DependencyInjection\ElasticsearchExtension;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
class Elasticsearch extends Bundle
{
protected $name = 'Elasticsearch';
public function build(ContainerBuilder $container): void
{
parent::build($container);
$this->buildConfig($container);
}
public function createContainerExtension()
{
return new ElasticsearchExtension();
}
private function buildConfig(ContainerBuilder $container): void
{
$locator = new FileLocator('Resources/config');
$resolver = new LoaderResolver([
new XmlFileLoader($container, $locator),
new YamlFileLoader($container, $locator),
new IniFileLoader($container, $locator),
new PhpFileLoader($container, $locator),
new GlobFileLoader($container, $locator),
new DirectoryLoader($container, $locator),
new ClosureLoader($container),
]);
$configLoader = new DelegatingLoader($resolver);
$confDir = $this->getPath() . '/Resources/config';
$configLoader->load($confDir . '/{packages}/*' . Kernel::CONFIG_EXTS, 'glob');
$env = $container->getParameter('kernel.environment');
$configLoader->load($confDir . '/{packages}/' . $env . '/*' . Kernel::CONFIG_EXTS, 'glob');
}
}