custom/plugins/PickwareGls/vendor/pickware/debug-bundle/src/ShopwarePluginsDebugBundle.php line 21

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright (c) Pickware GmbH. All rights reserved.
  4.  * This file is part of software that is released under a proprietary license.
  5.  * You must not copy, modify, distribute, make publicly available, or execute
  6.  * its contents or parts thereof without express permission by the copyright
  7.  * holder, unless otherwise permitted by law.
  8.  */
  9. declare(strict_types=1);
  10. namespace Pickware\DebugBundle;
  11. use Shopware\Core\Framework\Bundle;
  12. use Shopware\Core\Framework\Migration\MigrationSource;
  13. use Shopware\Core\Framework\Struct\Collection;
  14. use Symfony\Component\Config\FileLocator;
  15. use Symfony\Component\DependencyInjection\ContainerBuilder;
  16. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  17. class ShopwarePluginsDebugBundle extends Bundle
  18. {
  19.     private static ?self $instance null;
  20.     private static bool $registered false;
  21.     private static bool $migrationsRegistered false;
  22.     public static function register(Collection $bundleCollection): void
  23.     {
  24.         if (!self::$registered) {
  25.             $bundleCollection->add(self::getInstance());
  26.         }
  27.         self::$registered true;
  28.     }
  29.     public static function registerMigrations(MigrationSource $migrationSource): void
  30.     {
  31.         if (self::$migrationsRegistered) {
  32.             return;
  33.         }
  34.         $migrationsPath self::getInstance()->getMigrationPath();
  35.         $migrationNamespace self::getInstance()->getMigrationNamespace();
  36.         $migrationSource->addDirectory($migrationsPath$migrationNamespace);
  37.         self::$migrationsRegistered true;
  38.     }
  39.     public static function getInstance(): self
  40.     {
  41.         if (!self::$instance) {
  42.             self::$instance = new self();
  43.         }
  44.         return self::$instance;
  45.     }
  46.     public function build(ContainerBuilder $containerBuilder): void
  47.     {
  48.         parent::build($containerBuilder);
  49.         $loader = new XmlFileLoader($containerBuilder, new FileLocator(__DIR__));
  50.         $loader->load('DependencyInjection/service.xml');
  51.         $loader->load('ResponseExceptionListener/DependencyInjection/decorator.xml');
  52.         $loader->load('ResponseExceptionListener/DependencyInjection/service.xml');
  53.     }
  54.     public function boot(): void
  55.     {
  56.         parent::boot();
  57.         PickwareDebug::initialize($this->container);
  58.     }
  59.     public function shutdown(): void
  60.     {
  61.         parent::shutdown();
  62.         // Shopware may reboot the kernel under certain circumstances (e.g. plugin un-/installation) within a single
  63.         // request. After the kernel was rebooted, our bundles have to be registered again.
  64.         // We reset the registration flag when the kernel is shut down. This will cause the bundles to be registered
  65.         // again in the (re)boot process.
  66.         self::$registered false;
  67.     }
  68. }