custom/plugins/PickwareDhl/vendor/pickware/shopware-extensions-bundle/src/PickwareShopwareExtensionsBundle.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\ShopwareExtensionsBundle;
  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 PickwareShopwareExtensionsBundle 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.             return;
  26.         }
  27.         $bundleCollection->add(self::getInstance());
  28.         self::$registered true;
  29.     }
  30.     public static function registerMigrations(MigrationSource $migrationSource): void
  31.     {
  32.         if (self::$migrationsRegistered) {
  33.             return;
  34.         }
  35.         $migrationsPath self::getInstance()->getMigrationPath();
  36.         $migrationNamespace self::getInstance()->getMigrationNamespace();
  37.         $migrationSource->addDirectory($migrationsPath$migrationNamespace);
  38.         self::$migrationsRegistered true;
  39.     }
  40.     public static function getInstance(): self
  41.     {
  42.         if (!self::$instance) {
  43.             self::$instance = new self();
  44.         }
  45.         return self::$instance;
  46.     }
  47.     public function build(ContainerBuilder $containerBuilder): void
  48.     {
  49.         parent::build($containerBuilder);
  50.         $loader = new XmlFileLoader($containerBuilder, new FileLocator(__DIR__));
  51.         $loader->load('OrderDelivery/DependencyInjection/controller.xml');
  52.         $loader->load('OrderDelivery/DependencyInjection/service.xml');
  53.         $loader->load('OrderDocument/DependencyInjection/service.xml');
  54.         $loader->load('StateTransitioning/DependencyInjection/service.xml');
  55.     }
  56.     public function boot(): void
  57.     {
  58.         parent::boot();
  59.         // Shopware may reboot the kernel under certain circumstances. After the kernel was rebooted, our bundles have
  60.         // to be registered again. Since there does not seem to be a way to detect a reboot, we reset the registration
  61.         // flag immediately after the bundle has been booted. This will cause the bundles to be registered again when
  62.         // the method self::register is called the next time, which will only happen in the case of a kernel reboot.
  63.         self::$registered false;
  64.     }
  65. }