custom/plugins/PickwareErpStarter/vendor/pickware/config-bundle/src/PickwareConfigBundle.php line 25

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\ConfigBundle;
  11. use Pickware\BundleInstaller\BundleInstaller;
  12. use Pickware\DalBundle\DalBundle;
  13. use Shopware\Core\Framework\Bundle;
  14. use Shopware\Core\Framework\Migration\MigrationSource;
  15. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  16. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  17. use Shopware\Core\Framework\Struct\Collection;
  18. use Symfony\Component\Config\FileLocator;
  19. use Symfony\Component\DependencyInjection\ContainerBuilder;
  20. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  21. class PickwareConfigBundle extends Bundle
  22. {
  23.     /**
  24.      * @var class-string<Bundle>[]
  25.      */
  26.     private const ADDITIONAL_BUNDLES = [DalBundle::class];
  27.     private static ?self $instance null;
  28.     private static bool $registered false;
  29.     public static function register(Collection $bundleCollection): void
  30.     {
  31.         if (self::$registered) {
  32.             return;
  33.         }
  34.         $bundleCollection->add(self::getInstance());
  35.         foreach (self::ADDITIONAL_BUNDLES as $bundle) {
  36.             $bundle::register($bundleCollection);
  37.         }
  38.         self::$registered true;
  39.     }
  40.     public static function registerMigrations(MigrationSource $migrationSource): void
  41.     {
  42.     }
  43.     public static function getInstance(): self
  44.     {
  45.         if (!self::$instance) {
  46.             self::$instance = new self();
  47.         }
  48.         return self::$instance;
  49.     }
  50.     public function build(ContainerBuilder $containerBuilder): void
  51.     {
  52.         parent::build($containerBuilder);
  53.         $loader = new XmlFileLoader($containerBuilder, new FileLocator(__DIR__));
  54.         $loader->load('DependencyInjection/service.xml');
  55.     }
  56.     public function shutdown(): void
  57.     {
  58.         parent::shutdown();
  59.         // Shopware may reboot the kernel under certain circumstances (e.g. plugin un-/installation) within a single
  60.         // request. After the kernel was rebooted, our bundles have to be registered again.
  61.         // We reset the registration flag when the kernel is shut down. This will cause the bundles to be registered
  62.         // again in the (re)boot process.
  63.         self::$registered false;
  64.     }
  65.     public function install(InstallContext $installContext): void
  66.     {
  67.         BundleInstaller::createForContainerAndClass($this->containerself::class)
  68.             ->install(self::ADDITIONAL_BUNDLES$installContext);
  69.     }
  70.     public function onAfterActivate(InstallContext $installContext): void
  71.     {
  72.         BundleInstaller::createForContainerAndClass($this->containerself::class)
  73.             ->onAfterActivate(self::ADDITIONAL_BUNDLES$installContext);
  74.     }
  75.     public function uninstall(UninstallContext $uninstallContext): void
  76.     {
  77.         BundleInstaller::createForContainerAndClass($this->containerself::class)->uninstall($uninstallContext);
  78.     }
  79. }