vendor/coreshop/resource-bundle/CoreShopResourceBundle.php line 37

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * CoreShop
  5.  *
  6.  * This source file is available under two different licenses:
  7.  *  - GNU General Public License version 3 (GPLv3)
  8.  *  - CoreShop Commercial License (CCL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  * @copyright  Copyright (c) CoreShop GmbH (https://www.coreshop.org)
  13.  * @license    https://www.coreshop.org/license     GPLv3 and CCL
  14.  *
  15.  */
  16. namespace CoreShop\Bundle\ResourceBundle;
  17. use Composer\InstalledVersions;
  18. use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\DoctrineTargetEntitiesResolverPass;
  19. use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\PimcoreCachePass;
  20. use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterInstallersPass;
  21. use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterPimcoreRepositoriesPass;
  22. use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterPimcoreResourcesPass;
  23. use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterResourcesPass;
  24. use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\StackClassesPass;
  25. use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\StackRepositoryPass;
  26. use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\ValidatorAutoMappingFixPass;
  27. use JMS\SerializerBundle\JMSSerializerBundle;
  28. use Pimcore\Extension\Bundle\AbstractPimcoreBundle;
  29. use Pimcore\HttpKernel\Bundle\DependentBundleInterface;
  30. use Pimcore\HttpKernel\BundleCollection\BundleCollection;
  31. use Symfony\Component\DependencyInjection\ContainerBuilder;
  32. final class CoreShopResourceBundle extends AbstractPimcoreBundle implements DependentBundleInterface
  33. {
  34.     public const DRIVER_DOCTRINE_ORM 'doctrine/orm';
  35.     public const DRIVER_PIMCORE 'pimcore';
  36.     public const PIMCORE_MODEL_TYPE_OBJECT 'object';
  37.     public const PIMCORE_MODEL_TYPE_FIELD_COLLECTION 'fieldcollection';
  38.     public const PIMCORE_MODEL_TYPE_BRICK 'brick';
  39.     public function build(ContainerBuilder $container): void
  40.     {
  41.         parent::build($container);
  42.         $container->addCompilerPass(new RegisterResourcesPass());
  43.         $container->addCompilerPass(new RegisterPimcoreResourcesPass());
  44.         $container->addCompilerPass(new DoctrineTargetEntitiesResolverPass());
  45.         $container->addCompilerPass(new RegisterInstallersPass());
  46.         $container->addCompilerPass(new StackClassesPass());
  47.         $container->addCompilerPass(new StackRepositoryPass());
  48.         $container->addCompilerPass(new RegisterPimcoreRepositoriesPass());
  49.         $container->addCompilerPass(new ValidatorAutoMappingFixPass());
  50.         $container->addCompilerPass(new PimcoreCachePass());
  51.     }
  52.     public static function registerDependentBundles(BundleCollection $collection): void
  53.     {
  54.         $collection->addBundle(new JMSSerializerBundle(), 3900);
  55.         $collection->addBundle(new \CoreShop\Bundle\PimcoreBundle\CoreShopPimcoreBundle(), 3850);
  56.         $collection->addBundle(new \CoreShop\Bundle\OptimisticEntityLockBundle\CoreShopOptimisticEntityLockBundle(), 3800);
  57.         $collection->addBundle(new \CoreShop\Bundle\LocaleBundle\CoreShopLocaleBundle(), 3850);
  58.         $collection->addBundle(new \Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), 1200);
  59.     }
  60.     public function getNiceName(): string
  61.     {
  62.         return 'CoreShop - Resource';
  63.     }
  64.     public function getDescription(): string
  65.     {
  66.         return 'CoreShop - Resource Bundle';
  67.     }
  68.     public function getVersion(): string
  69.     {
  70.         if (class_exists('\\CoreShop\\Bundle\\CoreBundle\\Application\\Version')) {
  71.             return \CoreShop\Bundle\CoreBundle\Application\Version::getVersion() . ' (' $this->getComposerVersion() . ')';
  72.         }
  73.         return $this->getComposerVersion();
  74.     }
  75.     public function getComposerVersion(): string
  76.     {
  77.         $bundleName 'coreshop/resource-bundle';
  78.         if (class_exists(InstalledVersions::class)) {
  79.             if (InstalledVersions::isInstalled('coreshop/core-shop')) {
  80.                 return InstalledVersions::getPrettyVersion('coreshop/core-shop');
  81.             }
  82.             if (InstalledVersions::isInstalled($bundleName)) {
  83.                 return InstalledVersions::getPrettyVersion($bundleName);
  84.             }
  85.         }
  86.         return '';
  87.     }
  88.     public static function getAvailableDrivers(): array
  89.     {
  90.         return [
  91.             self::DRIVER_DOCTRINE_ORM,
  92.         ];
  93.     }
  94. }