<?php declare(strict_types=1);
namespace Shopware\Core\Profiling;
use Shopware\Core\Framework\Bundle;
use Shopware\Core\Kernel;
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\GlobFileLoader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
class Profiling extends Bundle
{
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container): void
{
parent::build($container);
$environment = $container->getParameter('kernel.environment');
$this->buildConfig($container, $environment);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/DependencyInjection/'));
$loader->load('services.xml');
}
private function buildConfig(ContainerBuilder $container, $environment): void
{
$locator = new FileLocator('Resources/config');
$resolver = new LoaderResolver([
new YamlFileLoader($container, $locator),
new GlobFileLoader($container, $locator),
]);
$configLoader = new DelegatingLoader($resolver);
$confDir = $this->getPath() . '/Resources/config';
$configLoader->load($confDir . '/{packages}/*' . Kernel::CONFIG_EXTS, 'glob');
$configLoader->load($confDir . '/{packages}/' . $environment . '/*' . Kernel::CONFIG_EXTS, 'glob');
}
}