vendor/shopware/core/Profiling/Profiling.php line 15

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Profiling;
  3. use Composer\InstalledVersions;
  4. use Shopware\Core\Framework\Bundle;
  5. use Shopware\Core\Framework\Log\Package;
  6. use Shopware\Core\Profiling\Compiler\RemoveDevServices;
  7. use Symfony\Component\Config\FileLocator;
  8. use Symfony\Component\DependencyInjection\ContainerBuilder;
  9. use Symfony\Component\DependencyInjection\ContainerInterface;
  10. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  11. use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
  12. /**
  13.  * @internal
  14.  */
  15. #[Package('core')]
  16. class Profiling extends Bundle
  17. {
  18.     public function getTemplatePriority(): int
  19.     {
  20.         return -2;
  21.     }
  22.     /**
  23.      * {@inheritdoc}
  24.      */
  25.     public function build(ContainerBuilder $container): void
  26.     {
  27.         /** @var string $environment */
  28.         $environment $container->getParameter('kernel.environment');
  29.         parent::build($container);
  30.         if (InstalledVersions::isInstalled('symfony/web-profiler-bundle')) {
  31.             $this->buildDefaultConfig($container);
  32.         }
  33.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection/'));
  34.         $loader->load('services.xml');
  35.         if ($environment === 'dev') {
  36.             $loader->load('services_dev.xml');
  37.         }
  38.         $container->addCompilerPass(new RemoveDevServices());
  39.     }
  40.     public function boot(): void
  41.     {
  42.         parent::boot();
  43.         \assert($this->container instanceof ContainerInterface'Container is not set yet, please call setContainer() before calling boot(), see `src/Core/Kernel.php:186`.');
  44.         // The profiler registers all profiler integrations in the constructor
  45.         // Therefor we need to get the service once to initialize it
  46.         $this->container->get(Profiler::class);
  47.     }
  48.     public function configureRoutes(RoutingConfigurator $routesstring $environment): void
  49.     {
  50.         if (!InstalledVersions::isInstalled('symfony/web-profiler-bundle')) {
  51.             return;
  52.         }
  53.         parent::configureRoutes($routes$environment);
  54.     }
  55. }